You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: Set correct branch when it's not specified in the config (#5844)
* feat: add helper for fetching default branch from Github
* feat: add method for setting default branch
* fix: set default branch after user has authenticated successfully
* fix: format code
* feat: add unit test for getting default branch name
* feat: add helpers for parsing API responses
* feat(lib-util): add helper for constructing request headers
* feat(lib-util): add helper for constructing full URL for API request
* feat(lib-util): store base URLs for each backend
* feat(lib-util): add type annotation for the request config
This requestConfig object will be passed to a helper for making API request
* feat(lib-util): add helper for handle API request error
* feat(lib-util): add config for making api request
* feat(lib-util): add api request generator
* feat(lib-util): add helper for getting default branch name
Include switch clause to construct API urls for different backends
* feat(lib-util): export method for getting default branch name
* feat(gh-backend): add a boolean property to check if branch is configured
The property is needed so that we'll only set default branch when branch prop is missing in config
* feat(gh-backend): set prop `branch` as `master` when it's missing in config
This is needed so that this property won't be empty when authorization is revoked.
* feat(gh-backend): set branch name when it's missing in config
* feat(gitlab-backend): set branch when it's not in the config
* feat(bitbucket-backend): set branch when it's not specified in config
* feat(lib-util): allow token type to be undefined
Reason: Requesting information from a public repo doesn't require token
* fix: format codes
* feat(github): removed setDefaultBranch function
Reason: Default branch is already set when calling `authenticate` function
* feat(github): remove function for getting default branch
* fix (github): removed GithubRepo object because it was never used
* fix (gitlab test): Repeat response for getting project info 2 times
Reason: The endpoint for getting Gitlab project info is called twice.
Need to specify the number of times to repeat the same response as 2, or Nock will throw an error.
* fix(gitlab test): add property `default_branch` to project response
REASON: Getting a single project through `/projects/:id` returns an
object which contains `default_branch` property, among many other props.
The mock response needs to convey that.
* fix(gitlab test): reformat codes
* feat(lib util api): change function name
Change from `constructUrl` to `constructUrlWithParams` to indicate that
the returned url may contain query string
* feat(lib-util api): Change variable name for storing API roots
Change from `rootApi` to `apiRoots` to indicate that the varible contains
multiple values
* feat(lib-util api): Add varialbe for storing endpoint constants
* feat(lib-util api): Change the returned value for `getDefaultBranchName`
Reason: There's no `null` value for default_branch
* feat(api test): Import Nock module for mocking API requests
* feat(api test): Add default values for mocking API
Default values include: default branch name, mock tokens and mock repo slug
* feat(api test): Add mock response to getting a single repo
* feat(api test): Add function for itnercepting request to get single repo
* feat(api test): Add test for gettingDefaultBranchName
* feat(lib-util): reformat codes
* feat(jest config): add moduleNameMapper for GitHub and BitBucket
Required for the test that checks setDefaultBranchName is called in lib-util to work
* feat(lib-util test): return some modules from backend core for testing
* feat(lib-util test): add owner login value for Github's repo response
The authenticate method of Github API wrapper extracts owner.login from repo resp
* feat(lib-util test): change access level for Gitlab to 30
Reason: If access level is under 30, Gitlab package will throw error
* feat(lib-util test): add mock response for getting a user
The authenticate method of each backend requires this
* feat(lib-util test): add default config for backend field
* feat(lib-util test): rewrite function for mocking API
* feat(lib-util test): rewrite function for mocking request for repo
* test(lib-util): rewrite test for the function getDefaultBranchName
* test(lib-util): add function for resolving backend
* test(lib-util): import 'set' module from Lodash
* test(lib-util): add helper for constructing url path for each backend
* test(lib-util): add function for intercepting API request to authenticate
* test(lib-util): import each backend module
* test(lib-util): add tests that check each backend calls getDefaultBranchName
* style: format files
* fix: query branch name before setting Github API service
* fix: reformat implementation module of Github backend
* fix: remove importing of getDefaultBranchName from lib
* fix: removed test for getDefaultBranchName in lib packages
* fix: removed unused vars in api test for lib package
* feat: retrieve default branch before creating Bitbucket AI instance
* fix: reformat codes in Bitbucket implementation module
* fix: add missing import
---------
Co-authored-by: Erez Rokah <[email protected]>
Co-authored-by: Martin Jagodic <[email protected]>
Co-authored-by: Anze Demsar <[email protected]>
0 commit comments