Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to save
Git
login temporarily (#1099)
* Adjust git command handlers - Adjust git push, pull, fetch, clone handlers, allowing `auth` and `cache_credentials` to be passed in in requests. - Allow `credential.helper` to pass through `git config` handler's filters. * Add `credential_helper` to server settings Allow users to configure the value of `credential_helper` to be used in the credentials caching logic. * Implement logic for setting git credential helper Implemennt methods that ensure `credential.helper` in `git config` to be used for credentials caching. * Extend git commands to support credentials caching Extend git command logics (push, pull, fetch, clone) to support credentials caching when `auth` is provided. * Add tests for the new credentials caching logic Add tests to test the newly-implemented credentials caching logic for `git push`, `git pull`, `git fetch` and `git clone`. * Extend `Git.IAuth` and `CredentialsBox` Extend `Git.IAuth` and `CredentialsBox` for credentials caching. There is a checkbox for saving Git credentials temporarily. Stylings are also made for `CredentialsBox`. `jp-RedirectForm` does not work well with `input` checkboxes. * Extend `clone()`, `push()`, `pull()` in model Let each of these methods also include `auth?.cacheCredentials` to POST to the backend. * Extend model for `_fetchRemotes()` Add extra class members to take care of the fetch poll when credentials are required. * Implement `fetch()` Add method `fetch()` that is similar to how `push()` or `pull()` works. `_fetchRemotes()` now calls `fetch()`, and if credentials are required, blocks further calls and signals a credentials requirement status change. * Remove a redundant member `_fetchBlocked` is not needed. * Extend `showGitOperationDialog()` This dialog now supports `fetch` operation, and upon successful authentication, unblocks the fetch poll by changing the credentials requirement state to `false`. * Match the `IGitExtension` with `push()` in model Also let `showGitOperationDialog()` accept `IGitExtension` `model` instead of the concrete class `GitExtension`. * Extend `StatusWidget` The component now has a boolean for Git credentials requirement. Also add a callback connected to the model to update that boolean. * Reuse `showGitOperationDialog()` in `StatusWidget` Inject the model to the component and reuse `showGitOperationDialog()` for the `fetch` operation. * Add a notification dot to `StatusWidget` Add a notification dot to the component so that it looks like the `push` (when the local branch is ahead) button and `pull` button (when the local branch is behind) on the top toolbar in the Git panel. * Implement `ensure_git_credential_cache_daemon()` This method spawns a Git credential cache daemon so that the caching mechanism can work. * Extend `check/ensure_credential_helper()` Let these methods check if a cache daemon is required, and invoke `ensure_git_credential_cache_daemon()` if on Linux, or else respond with an error message. * Refactor `push/pull/fetch/clone` Let them return an error response if the credential helper cannot be ensured. * Refactor and adjust tests to adopt new changes - Use `assert_awaited_` instead of `assert_called_` in some places. - Use `assert_has_awaits` instead of `assert_has_calls` in some places. - Use name `mock_execute` instead of `mock_authentication`. - Mock `sys.platform` as `"linux"`. - Make sure the `ensure_git_credential_cache_daemon()` is called accordingly. * Include `"message"` in `fetch()`'s response This is so that the front-end can recognize this response with `IResultWithMessage`. * Lint files with ESLint * Adjust `test_handlers.py` to adopt new changes Add argument `cache_credentials` to assertions. * Revert `await` back to `call` This is for compatibility with Python 3.7's `unittest`. * Adopt PR review suggestions /pull/1099#pullrequestreview-919970442 * Fix CI - /pull/1099#pullrequestreview-926143691 - Remove redundant tests - Adjust tests to match changed method signatures - Add a missing `self.config()` call when ensuring Git credential helper * Reformat `model.ts` with Prettier Also fix a minor typo. Co-authored-by: Dat Quach <[email protected]> Co-authored-by: Zeshan Fayyaz <[email protected]>
- Loading branch information