Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add setting to disable auto select profile #98

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Ever wanted to use different username and email addresses for your commits at wo

> Latest Changes
>
> - ✅ Add support for `signingkey`.
> - ✅ Add supports deleting profiles - Type 'git config profiles' in command palette and select 'Delete a profile'.
> - ✅ Add Migrate old profiles to new format.
> - 🐞 Fix Crash with old profiles.
> - ✅ If the repository's git config matches a defined profile, extension now selects it automatically. Don't like this behaviour and prefer the old way? You can disable it in settings.
> ![auto select](images/marketplace/auto-select-profile-setting.png)
> - ✅ Store `signingkey` in the profile.
> - ✅ Delete Profile - Type 'git config profiles' in command palette and select 'Delete a profile'.

![demo](images/marketplace/demo.gif)

Expand Down Expand Up @@ -38,6 +38,17 @@ Click `Pick a profile` and then select a profile you need.

### Setting the profile selected to the repo
---

#### Auto selection of profile

When the extension loads up, it looks up the local git config and tries to match it with the profiles defined. If it finds a match, it selects the profile automatically (new behaviour). This behavior can be disabled in settings.

![auto select](images/marketplace/auto-select-profile-setting.png)

#### Manual selection of profile

If auto selection of profile is disabled, the status bar will show a warning if the repository's username and email do not match any of the profiles, and you can select a profile manually (old behaviour).

Once you select a profile, the status bar text changes to selected profile name [1 in image below].

> The icon might display a "warning" sign if the current repo is not using the username and email selected.
Expand All @@ -46,13 +57,14 @@ If you want to apply the username and email defined in the selected profile to t

![profile not in sync](images/marketplace/repo-not-in-sync.png)

Once the repository's username and email are in sync, you might see a check icon confirming that repository config is in sync with the profile selected.
Once the repository's username and email are in sync, you will see warning color go away confirming that repository config is in sync with the profile selected.

![repo in sync](images/marketplace/repo-in-sync.png)

### Issues and feature requests
### Deleting a profile
Open the Command Palette and type `git config user profiles` or `gcup` and select `Delete a profile`. You will be presented with a list of profiles to delete.

If you find any bug or have any suggestion/feature request, please submit the [issue](https://github.com/onlyutkarsh/git-config-user-profiles/issues) in the GitHub repo. It is helpful to troubleshoot if you paste results of `Output` window when submitting issues.
### Issues and feature requests

![output window](images/marketplace/outputwindow.png)
If you find any bug or have any suggestion/feature request, please submit the [issue](https://github.com/onlyutkarsh/git-config-user-profiles/issues) in the GitHub repo.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
},
"default": [],
"description": "Git Config User Profiles configuration"
},
"gitConfigUser.selectMatchedProfileAutomatically": {
"type": "boolean",
"default": true,
"markdownDescription": "Select the matched profile automatically when opening a workspace"
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/util/gitManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ export async function getWorkspaceStatus(): Promise<{
const matchedProfileToLocalConfig = profilesInVscConfig.find(
(x) => x.userName === currentGitConfig.userName && x.email === currentGitConfig.email && x.signingKey === currentGitConfig.signingKey
);
if (matchedProfileToLocalConfig) {
const selectMatchedProfileAutomatically = await vscode.workspace.getConfiguration("gitConfigUser").get("selectMatchedProfileAutomatically");
Logger.instance.logInfo(`Select matched profile automatically: ${selectMatchedProfileAutomatically}`);
if (matchedProfileToLocalConfig && selectMatchedProfileAutomatically === true) {
if (selectedVscProfile && selectedVscProfile.id !== matchedProfileToLocalConfig.id) {
// if matching profile exists, but the selected profile is different, we should select matched profile automatically
Logger.instance.logInfo(`Current git config matches '${matchedProfileToLocalConfig.label}'. Selecting it automatically.`);
Expand Down