Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 5da35e9

Browse files
committed
We can only run local git commands if there's a git repo
1 parent 3e621d5 commit 5da35e9

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -163,34 +163,37 @@ public void SetupGit(GitInstaller.GitInstallationState state)
163163

164164
if (firstRun)
165165
{
166-
var unityYamlMergeExec = Environment.UnityApplicationContents.Combine("Tools", "UnityYAMLMerge" + Environment.ExecutableExtension);
166+
if (Environment.RepositoryPath.IsInitialized)
167+
{
168+
var unityYamlMergeExec = Environment.UnityApplicationContents.Combine("Tools", "UnityYAMLMerge" + Environment.ExecutableExtension);
169+
var yamlMergeCommand = Environment.IsWindows
170+
? $@"'{unityYamlMergeExec}' merge -p ""$BASE"" ""$REMOTE"" ""$LOCAL"" ""$MERGED"""
171+
: $@"'{unityYamlMergeExec}' merge -p '$BASE' '$REMOTE' '$LOCAL' '$MERGED'";
167172

168-
var yamlMergeCommand = Environment.IsWindows
169-
? $@"'{unityYamlMergeExec}' merge -p ""$BASE"" ""$REMOTE"" ""$LOCAL"" ""$MERGED"""
170-
: $@"'{unityYamlMergeExec}' merge -p '$BASE' '$REMOTE' '$LOCAL' '$MERGED'";
173+
GitClient.SetConfig("merge.unityyamlmerge.cmd", yamlMergeCommand, GitConfigSource.Local)
174+
.Catch(e =>
175+
{
176+
Logger.Error(e, "Error setting merge.unityyamlmerge.cmd");
177+
return true;
178+
})
179+
.RunWithReturn(true);
171180

172-
GitClient.SetConfig("merge.unityyamlmerge.cmd", yamlMergeCommand, GitConfigSource.Local)
173-
.Catch(e =>
174-
{
175-
Logger.Error(e, "Error setting merge.unityyamlmerge.cmd");
176-
return true;
177-
})
178-
.RunWithReturn(true);
179-
GitClient.SetConfig("merge.unityyamlmerge.trustExitCode", "false", GitConfigSource.Local)
180-
.Catch(e =>
181-
{
182-
Logger.Error(e, "Error setting merge.unityyamlmerge.trustExitCode");
183-
return true;
184-
})
185-
.RunWithReturn(true);
181+
GitClient.SetConfig("merge.unityyamlmerge.trustExitCode", "false", GitConfigSource.Local)
182+
.Catch(e =>
183+
{
184+
Logger.Error(e, "Error setting merge.unityyamlmerge.trustExitCode");
185+
return true;
186+
})
187+
.RunWithReturn(true);
186188

187-
GitClient.LfsInstall()
188-
.Catch(e =>
189-
{
190-
Logger.Error(e, "Error running lfs install");
191-
return true;
192-
})
193-
.RunWithReturn(true);
189+
GitClient.LfsInstall()
190+
.Catch(e =>
191+
{
192+
Logger.Error(e, "Error running lfs install");
193+
return true;
194+
})
195+
.RunWithReturn(true);
196+
}
194197

195198
if (Environment.IsWindows)
196199
{

0 commit comments

Comments
 (0)