Thanks to visit codestin.com
Credit goes to github.com

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

Commit a6c4016

Browse files
authored
Merge pull request #744 from github-for-unity/fixes/configure-merge-settings-on-repo-init-too
Setting UnityYamlMerge options on repo initialization
2 parents 4f30255 + 60fb751 commit a6c4016

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,26 +165,7 @@ public void SetupGit(GitInstaller.GitInstallationState state)
165165
{
166166
if (Environment.RepositoryPath.IsInitialized)
167167
{
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'";
172-
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);
180-
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);
168+
ConfigureMergeSettings();
188169

189170
GitClient.LfsInstall()
190171
.Catch(e =>
@@ -236,6 +217,8 @@ public void InitializeRepository()
236217
var filesForInitialCommit = new List<string> { gitignore, gitAttrs, assetsGitignore };
237218

238219
GitClient.Init().RunWithReturn(true);
220+
221+
ConfigureMergeSettings();
239222
GitClient.LfsInstall().RunWithReturn(true);
240223
AssemblyResources.ToFile(ResourceType.Generic, ".gitignore", targetPath, Environment);
241224
AssemblyResources.ToFile(ResourceType.Generic, ".gitattributes", targetPath, Environment);
@@ -261,6 +244,25 @@ public void InitializeRepository()
261244
thread.Start();
262245
}
263246

247+
private void ConfigureMergeSettings()
248+
{
249+
var unityYamlMergeExec =
250+
Environment.UnityApplicationContents.Combine("Tools", "UnityYAMLMerge" + Environment.ExecutableExtension);
251+
var yamlMergeCommand = Environment.IsWindows
252+
? $@"'{unityYamlMergeExec}' merge -p ""$BASE"" ""$REMOTE"" ""$LOCAL"" ""$MERGED"""
253+
: $@"'{unityYamlMergeExec}' merge -p '$BASE' '$REMOTE' '$LOCAL' '$MERGED'";
254+
255+
GitClient.SetConfig("merge.unityyamlmerge.cmd", yamlMergeCommand, GitConfigSource.Local).Catch(e => {
256+
Logger.Error(e, "Error setting merge.unityyamlmerge.cmd");
257+
return true;
258+
}).RunWithReturn(true);
259+
260+
GitClient.SetConfig("merge.unityyamlmerge.trustExitCode", "false", GitConfigSource.Local).Catch(e => {
261+
Logger.Error(e, "Error setting merge.unityyamlmerge.trustExitCode");
262+
return true;
263+
}).RunWithReturn(true);
264+
}
265+
264266
public void RestartRepository()
265267
{
266268
if (!Environment.RepositoryPath.IsInitialized)

0 commit comments

Comments
 (0)