diff --git a/README.md b/README.md index 036ea0a..e42ca18 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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. @@ -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. diff --git a/images/marketplace/auto-select-profile-setting.png b/images/marketplace/auto-select-profile-setting.png new file mode 100644 index 0000000..0f3d35b Binary files /dev/null and b/images/marketplace/auto-select-profile-setting.png differ diff --git a/package.json b/package.json index 90bad96..4a24bc6 100644 --- a/package.json +++ b/package.json @@ -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" } } } diff --git a/src/util/gitManager.ts b/src/util/gitManager.ts index 1eb1fbf..8951b0b 100644 --- a/src/util/gitManager.ts +++ b/src/util/gitManager.ts @@ -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.`);