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

Commit 423f38d

Browse files
Merge branch 'master' into master
2 parents 6796651 + 05f7e95 commit 423f38d

File tree

16 files changed

+329
-62
lines changed

16 files changed

+329
-62
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Have you read GitHub for Unity's Code of Conduct? By filing an Issue, you are ex
1010
- Include the log file in the PR.
1111
- On Windows, the extension log file is at `%LOCALAPPDATA%\GitHubUnity\github-unity.log`
1212
- On macOS, the extension log file is at `~/Library/Logs/GitHubUnity/github-unity.log`
13+
- On linux, the extension log file is at `~/.local/share/GitHubUnity/github-unity.log`
1314

1415
### Description
1516

common/SolutionInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ namespace System
3232
{
3333
internal static class AssemblyVersionInformation {
3434
// this is for the AssemblyVersion and AssemblyVersion attributes, which can't handle alphanumerics
35-
internal const string VersionForAssembly = "1.1.1";
35+
internal const string VersionForAssembly = "1.2.0";
3636
// Actual real version
37-
internal const string Version = "1.1.1";
37+
internal const string Version = "1.2.0";
3838
}
3939
}

src/GitHub.Api/Application/ApiClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public void LoginWithToken(string token, Action<bool> result)
262262
Guard.ArgumentNotNull(result, "result");
263263

264264
new FuncTask<bool>(taskManager.Token,
265-
() => loginManager.LoginWithToken(UriString.ToUriString(HostAddress.WebUri), token))
265+
() => loginManager.LoginWithToken(HostAddress.WebUri.Host, token))
266266
.FinallyInUI((success, ex, res) =>
267267
{
268268
if (!success)

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public void SetupGit(GitInstaller.GitInstallationState state)
190190
{
191191
if (Environment.RepositoryPath.IsInitialized)
192192
{
193-
ConfigureMergeSettings();
193+
UpdateMergeSettings();
194194

195195
GitClient.LfsInstall()
196196
.Catch(e =>
@@ -280,25 +280,58 @@ public void InitializeRepository()
280280
thread.Start();
281281
}
282282

283-
private void ConfigureMergeSettings()
283+
private void ConfigureMergeSettings(string keyName = null)
284284
{
285285
var unityYamlMergeExec =
286286
Environment.UnityApplicationContents.Combine("Tools", "UnityYAMLMerge" + Environment.ExecutableExtension);
287-
var yamlMergeCommand = Environment.IsWindows
288-
? $@"'{unityYamlMergeExec}' merge -p ""$BASE"" ""$REMOTE"" ""$LOCAL"" ""$MERGED"""
289-
: $@"'{unityYamlMergeExec}' merge -p '$BASE' '$REMOTE' '$LOCAL' '$MERGED'";
290287

291-
GitClient.SetConfig("merge.unityyamlmerge.cmd", yamlMergeCommand, GitConfigSource.Local).Catch(e => {
292-
Logger.Error(e, "Error setting merge.unityyamlmerge.cmd");
288+
var yamlMergeCommand = $"'{unityYamlMergeExec}' merge -h -p --force %O %B %A %A";
289+
290+
keyName = keyName ?? "unityyamlmerge";
291+
292+
GitClient.SetConfig($"merge.{keyName}.name", "Unity SmartMerge (UnityYamlMerge)", GitConfigSource.Local).Catch(e => {
293+
Logger.Error(e, "Error setting merge." + keyName + ".name");
294+
return true;
295+
}).RunSynchronously();
296+
297+
GitClient.SetConfig($"merge.{keyName}.driver", yamlMergeCommand, GitConfigSource.Local).Catch(e => {
298+
Logger.Error(e, "Error setting merge." + keyName + ".driver");
293299
return true;
294300
}).RunSynchronously();
295301

296-
GitClient.SetConfig("merge.unityyamlmerge.trustExitCode", "false", GitConfigSource.Local).Catch(e => {
297-
Logger.Error(e, "Error setting merge.unityyamlmerge.trustExitCode");
302+
GitClient.SetConfig($"merge.{keyName}.recursive", "binary", GitConfigSource.Local).Catch(e => {
303+
Logger.Error(e, "Error setting merge." + keyName + ".recursive");
298304
return true;
299305
}).RunSynchronously();
300306
}
301307

308+
private void UpdateMergeSettings()
309+
{
310+
var gitAttributesPath = Environment.RepositoryPath.Combine(".gitattributes");
311+
if (gitAttributesPath.FileExists())
312+
{
313+
var readAllText = gitAttributesPath.ReadAllText();
314+
var containsLegacyUnityYamlMergeError = readAllText.Contains("unityamlmerge");
315+
316+
if (containsLegacyUnityYamlMergeError)
317+
{
318+
ConfigureMergeSettings("unityamlmerge");
319+
}
320+
}
321+
322+
GitClient.UnSetConfig("merge.unityyamlmerge.cmd", GitConfigSource.Local).Catch(e => {
323+
Logger.Error(e, "Error removing merge.unityyamlmerge.cmd");
324+
return true;
325+
}).RunSynchronously();
326+
327+
GitClient.UnSetConfig("merge.unityyamlmerge.trustExitCode", GitConfigSource.Local).Catch(e => {
328+
Logger.Error(e, "Error removing merge.unityyamlmerge.trustExitCode");
329+
return true;
330+
}).RunSynchronously();
331+
332+
ConfigureMergeSettings();
333+
}
334+
302335
public void RestartRepository()
303336
{
304337
if (!Environment.RepositoryPath.IsInitialized)

src/GitHub.Api/Git/GitClient.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ public interface IGitClient
6060
/// <returns>String output of git command</returns>
6161
ITask<string> SetConfig(string key, string value, GitConfigSource configSource, IOutputProcessor<string> processor = null);
6262

63+
/// <summary>
64+
/// Executes `git config --unset` to remove a configuration value.
65+
/// </summary>
66+
/// <param name="key">The configuration key to remove</param>
67+
/// <param name="configSource">The config source (unspecified, local,user,global) to use</param>
68+
/// <param name="processor">A custom output processor instance</param>
69+
/// <returns>String output of git command</returns>
70+
ITask<string> UnSetConfig(string key, GitConfigSource configSource, IOutputProcessor<string> processor = null);
71+
6372
/// <summary>
6473
/// Executes two `git config get` commands to get the git user and email.
6574
/// </summary>
@@ -394,6 +403,13 @@ public ITask<string> SetConfig(string key, string value, GitConfigSource configS
394403
.Configure(processManager);
395404
}
396405

406+
///<inheritdoc/>
407+
public ITask<string> UnSetConfig(string key, GitConfigSource configSource, IOutputProcessor<string> processor = null)
408+
{
409+
return new GitConfigUnSetTask(key, configSource, cancellationToken, processor)
410+
.Configure(processManager);
411+
}
412+
397413
///<inheritdoc/>
398414
public ITask<GitUser> GetConfigUserAndEmail()
399415
{

src/GitHub.Api/Git/Tasks/GitConfigSetTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ public GitConfigSetTask(string key, string value, GitConfigSource configSource,
2525
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
2626
public override string Message { get; set; } = "Writing configuration...";
2727
}
28-
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Threading;
3+
4+
namespace GitHub.Unity
5+
{
6+
class GitConfigUnSetTask : ProcessTask<string>
7+
{
8+
private readonly string arguments;
9+
10+
public GitConfigUnSetTask(string key, GitConfigSource configSource,
11+
CancellationToken token, IOutputProcessor<string> processor = null)
12+
: base(token, processor ?? new SimpleOutputProcessor())
13+
{
14+
var source = "";
15+
source +=
16+
configSource == GitConfigSource.NonSpecified ? "--unset" :
17+
configSource == GitConfigSource.Local ? "--local --unset" :
18+
configSource == GitConfigSource.User ? "--global --unset" :
19+
"--system --unset";
20+
arguments = String.Format("config {0} {1}", source, key);
21+
Name = String.Format("config {0} {1}", source, key);
22+
}
23+
24+
public override string ProcessArguments { get { return arguments; } }
25+
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
26+
public override string Message { get; set; } = "Writing configuration...";
27+
}
28+
}

src/GitHub.Api/GitHub.Api.45.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<Compile Include="Git\Tasks\GitCheckoutTask.cs" />
8383
<Compile Include="Git\GitAheadBehindStatus.cs" />
8484
<Compile Include="Git\Tasks\GitAheadBehindStatusTask.cs" />
85+
<Compile Include="Git\Tasks\GitConfigUnSetTask.cs" />
8586
<Compile Include="Git\Tasks\GitCountObjectsTask.cs" />
8687
<Compile Include="Git\Tasks\GitLfsVersionTask.cs" />
8788
<Compile Include="Git\Tasks\GitVersionTask.cs" />

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
<Compile Include="Git\Tasks\GitCheckoutTask.cs" />
9494
<Compile Include="Git\GitAheadBehindStatus.cs" />
9595
<Compile Include="Git\Tasks\GitAheadBehindStatusTask.cs" />
96+
<Compile Include="Git\Tasks\GitConfigUnSetTask.cs" />
9697
<Compile Include="Git\Tasks\GitCountObjectsTask.cs" />
9798
<Compile Include="Git\Tasks\GitLfsVersionTask.cs" />
9899
<Compile Include="Git\Tasks\GitVersionTask.cs" />

src/GitHub.Api/Installer/CopyHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static class CopyHelper
1212

1313
public static void Copy(NPath fromPath, NPath toPath)
1414
{
15-
Logger.Trace("Copying from " + fromPath + " to " + toPath + ".");
15+
Logger.Trace("Copying from {0} to {1}", fromPath, toPath);
1616

1717
try
1818
{
@@ -28,7 +28,7 @@ public static void Copy(NPath fromPath, NPath toPath)
2828
}
2929
catch (Exception ex2)
3030
{
31-
Logger.Error(ex1, "Error copying contents.");
31+
Logger.Error(ex2, "Error copying contents.");
3232
throw;
3333
}
3434
}
@@ -39,15 +39,15 @@ public static void Copy(NPath fromPath, NPath toPath)
3939
}
4040
public static void CopyFolder(NPath fromPath, NPath toPath)
4141
{
42-
Logger.Trace("CopyFolder fromPath: {0} toPath:{1}", fromPath.ToString(), toPath.ToString());
42+
Logger.Trace("CopyFolder from {0} to {1}", fromPath, toPath);
4343
toPath.DeleteIfExists();
4444
toPath.EnsureParentDirectoryExists();
4545
fromPath.Move(toPath);
4646
}
4747

4848
public static void CopyFolderContents(NPath fromPath, NPath toPath)
4949
{
50-
Logger.Trace("CopyFolder Contents fromPath: {0} toPath:{1}", fromPath.ToString(), toPath.ToString());
50+
Logger.Trace("CopyFolderContents from {0} to {1}", fromPath, toPath);
5151
toPath.DeleteContents();
5252
fromPath.MoveFiles(toPath, true);
5353
}

0 commit comments

Comments
 (0)