Skip to content

Commit 5f9bede

Browse files
authored
Do not query local bindings if outside repo in Azure Repos (#1561)
Do not attempt to query for an organisation/user binding in the local repository configuration if we're not currently inside of a repository! This will prevent the warning message from Git's standard error stream from flowing to our caller's stderr stream when GCM tries to use the `--local` option in a `git config` call. cc @markphip
2 parents d6432f9 + b28e11a commit 5f9bede

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/shared/Microsoft.AzureRepos/AzureReposBindingManager.cs

+9-5
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,15 @@ public AzureReposBinding GetBinding(string orgName)
9393

9494
_trace.WriteLine($"Looking up organization binding for '{orgName}'...");
9595

96-
// NOT using the short-circuiting OR operator here on purpose - we need both branches to be evaluated
97-
if (config.TryGet(GitConfigurationLevel.Local, GitConfigurationType.Raw,
98-
orgKey, out string localUser) |
99-
config.TryGet(GitConfigurationLevel.Global, GitConfigurationType.Raw,
100-
orgKey, out string globalUser))
96+
string localUser = null;
97+
bool hasLocal = _git.IsInsideRepository() && // Can only check local config if we are inside a repository
98+
config.TryGet(GitConfigurationLevel.Local, GitConfigurationType.Raw,
99+
orgKey, out localUser);
100+
101+
bool hasGlobal = config.TryGet(GitConfigurationLevel.Global, GitConfigurationType.Raw,
102+
orgKey, out string globalUser);
103+
104+
if (hasLocal || hasGlobal)
101105
{
102106
return new AzureReposBinding(orgName, globalUser, localUser);
103107
}

0 commit comments

Comments
 (0)