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

Commit b32218b

Browse files
Merge branch 'master' into fixes/remote-config-branch
2 parents 258eab9 + 974b6b1 commit b32218b

File tree

9 files changed

+75
-58
lines changed

9 files changed

+75
-58
lines changed

docs/contributing/how-to-build.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This repository is LFS-enabled. To clone it, you should use a git client that su
66

77
### Windows
88

9-
- Visual Studio 2015+ or Mono 4.x + bash shell (git bash).
9+
- Visual Studio 2015+ or [Mono 4.x](https://download.mono-project.com/archive/4.8.1/windows-installer/) + bash shell (git bash).
1010
- Mono 5.x will not work
1111
- `UnityEngine.dll` and `UnityEditor.dll`.
1212
- If you've installed Unity in the default location of `C:\Program Files\Unity` or `C:\Program Files (x86)\Unity`, the build will be able to reference these DLLs automatically. Otherwise, you'll need to copy these DLLs from `[Unity installation path]\Unity\Editor\Data\Managed` into the `lib` directory in order for the build to work
@@ -48,7 +48,7 @@ To build with Visual Studio 2015+, open the solution file `GitHub.Unity.sln`. Se
4848

4949
### Mono and Bash (windows and mac)
5050

51-
To build with Mono 4.x and Bash execute `build.sh` in a bash shell.
51+
To build with Mono 4.x and Bash, first ensure Mono is added to PATH. Mono installs to `C:\Program Files\Mono\bin\` by default. Then execute `build.sh` in a bash shell.
5252

5353
## Build Output
5454

src/GitHub.Api/Git/GitClient.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ ITask<string> Unlock(string file, bool force,
8383
ITask<Version> Version(IOutputProcessor<Version> processor = null);
8484

8585
ITask<Version> LfsVersion(IOutputProcessor<Version> processor = null);
86+
87+
ITask<User> SetConfigUserAndEmail(string username, string email);
8688
}
8789

8890
class GitClient : IGitClient
8991
{
92+
private const string UserNameConfigKey = "user.name";
93+
private const string UserEmailConfigKey = "user.email";
9094
private readonly IEnvironment environment;
9195
private readonly IProcessManager processManager;
9296
private readonly ITaskManager taskManager;
@@ -260,23 +264,30 @@ public ITask<User> GetConfigUserAndEmail()
260264
string username = null;
261265
string email = null;
262266

263-
return GetConfig("user.name", GitConfigSource.User)
267+
return GetConfig(UserNameConfigKey, GitConfigSource.User)
264268
.Then((success, value) => {
265269
if (success)
266270
{
267271
username = value;
268272
}
269273
})
270-
.Then(GetConfig("user.email", GitConfigSource.User)
274+
.Then(GetConfig(UserEmailConfigKey, GitConfigSource.User)
271275
.Then((success, value) => {
272276
if (success)
273277
{
274278
email = value;
275279
}
276280
})).Then(success => {
277-
Logger.Trace("{0}:{1} {2}:{3}", "user.name", username, "user.email", email);
278-
return new User { Name= username, Email = email };
279-
});
281+
Logger.Trace("{0}:{1} {2}:{3}", UserNameConfigKey, username, UserEmailConfigKey, email);
282+
return new User { Name = username, Email = email };
283+
});
284+
}
285+
286+
public ITask<User> SetConfigUserAndEmail(string username, string email)
287+
{
288+
return SetConfig(UserNameConfigKey, username, GitConfigSource.User)
289+
.Then(SetConfig(UserEmailConfigKey, email, GitConfigSource.User))
290+
.Then(b => new User { Name = username, Email = email });
280291
}
281292

282293
public ITask<List<GitLock>> ListLocks(bool local, BaseOutputListProcessor<GitLock> processor = null)

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class RepositoryManager : IRepositoryManager
9696
private readonly IGitClient gitClient;
9797
private readonly IPlatform platform;
9898
private readonly IRepositoryPathConfiguration repositoryPaths;
99-
private readonly ITaskManager taskManager;
10099
private readonly IRepositoryWatcher watcher;
101100

102101
private bool isBusy;
@@ -113,13 +112,12 @@ class RepositoryManager : IRepositoryManager
113112
public event Action<string, string> OnRemoteBranchRemoved;
114113
public event Action OnRepositoryUpdated;
115114

116-
public RepositoryManager(IPlatform platform, ITaskManager taskManager, IGitConfig gitConfig,
115+
public RepositoryManager(IPlatform platform, IGitConfig gitConfig,
117116
IRepositoryWatcher repositoryWatcher, IGitClient gitClient,
118117
IRepositoryPathConfiguration repositoryPaths)
119118
{
120119
this.repositoryPaths = repositoryPaths;
121120
this.platform = platform;
122-
this.taskManager = taskManager;
123121
this.gitClient = gitClient;
124122
this.watcher = repositoryWatcher;
125123
this.config = gitConfig;
@@ -136,7 +134,7 @@ public static RepositoryManager CreateInstance(IPlatform platform, ITaskManager
136134

137135
var repositoryWatcher = new RepositoryWatcher(platform, repositoryPathConfiguration, taskManager.Token);
138136

139-
return new RepositoryManager(platform, taskManager, gitConfig, repositoryWatcher,
137+
return new RepositoryManager(platform, gitConfig, repositoryWatcher,
140138
gitClient, repositoryPathConfiguration);
141139
}
142140

src/GitHub.Api/Helpers/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ static class Constants
99
public const string UsageFile = "usage.json";
1010
public const string GitInstallPathKey = "GitInstallPath";
1111
public const string TraceLoggingKey = "EnableTraceLogging";
12+
public const string Iso8601Format = "o";
1213

1314
public static readonly Version MinimumGitVersion = new Version(2, 11, 0);
1415
public static readonly Version MinimumGitLfsVersion = new Version(2, 3, 4);

src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ private void ReturnGitLogEntry()
329329
Summary = summary,
330330
Description = description,
331331
CommitID = commitId,
332-
TimeString = time.Value.ToString(DateTimeFormatInfo.CurrentInfo),
333-
CommitTimeString = committerTime.Value.ToString(DateTimeFormatInfo.CurrentInfo)
332+
TimeString = time.Value.ToString(Constants.Iso8601Format),
333+
CommitTimeString = committerTime.Value.ToString(Constants.Iso8601Format)
334334
});
335335
}
336336

src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
4-
using Octokit;
55
using UnityEditor;
66
using UnityEngine;
77
using Application = UnityEngine.Application;
@@ -92,7 +92,6 @@ abstract class ManagedCacheBase<T> : ScriptObjectSingleton<T> where T : Scriptab
9292
private static readonly TimeSpan DataTimeout = TimeSpan.MaxValue;
9393

9494
[NonSerialized] private DateTimeOffset? lastUpdatedAtValue;
95-
9695
[NonSerialized] private DateTimeOffset? lastVerifiedAtValue;
9796

9897
public event Action CacheInvalidated;
@@ -148,14 +147,22 @@ public DateTimeOffset LastUpdatedAt
148147
{
149148
if (!lastUpdatedAtValue.HasValue)
150149
{
151-
lastUpdatedAtValue = DateTimeOffset.Parse(LastUpdatedAtString);
150+
DateTimeOffset result;
151+
if (DateTimeOffset.TryParseExact(LastUpdatedAtString, Constants.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
152+
{
153+
lastUpdatedAtValue = result;
154+
}
155+
else
156+
{
157+
lastUpdatedAtValue = DateTimeOffset.MinValue;
158+
}
152159
}
153160

154161
return lastUpdatedAtValue.Value;
155162
}
156163
set
157164
{
158-
LastUpdatedAtString = value.ToString();
165+
LastUpdatedAtString = value.ToString(Constants.Iso8601Format);
159166
lastUpdatedAtValue = null;
160167
}
161168
}
@@ -166,14 +173,22 @@ public DateTimeOffset LastVerifiedAt
166173
{
167174
if (!lastVerifiedAtValue.HasValue)
168175
{
169-
lastVerifiedAtValue = DateTimeOffset.Parse(LastVerifiedAtString);
176+
DateTimeOffset result;
177+
if (DateTimeOffset.TryParseExact(LastVerifiedAtString, Constants.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
178+
{
179+
lastVerifiedAtValue = result;
180+
}
181+
else
182+
{
183+
lastVerifiedAtValue = DateTimeOffset.MinValue;
184+
}
170185
}
171186

172187
return lastVerifiedAtValue.Value;
173188
}
174189
set
175190
{
176-
LastVerifiedAtString = value.ToString();
191+
LastVerifiedAtString = value.ToString(Constants.Iso8601Format);
177192
lastVerifiedAtValue = null;
178193
}
179194
}

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/UserSettingsView.cs

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class UserSettingsView : Subview
2222
[SerializeField] private string gitEmail;
2323
[SerializeField] private string newGitName;
2424
[SerializeField] private string newGitEmail;
25+
[SerializeField] private bool needsSaving;
2526

2627
public override void InitializeView(IView parent)
2728
{
@@ -42,11 +43,17 @@ public override void OnGUI()
4243

4344
EditorGUI.BeginDisabledGroup(IsBusy || Parent.IsBusy);
4445
{
45-
newGitName = EditorGUILayout.TextField(GitConfigNameLabel, newGitName);
46-
newGitEmail = EditorGUILayout.TextField(GitConfigEmailLabel, newGitEmail);
46+
EditorGUI.BeginChangeCheck();
47+
{
48+
newGitName = EditorGUILayout.TextField(GitConfigNameLabel, newGitName);
49+
newGitEmail = EditorGUILayout.TextField(GitConfigEmailLabel, newGitEmail);
50+
}
4751

48-
var needsSaving = (newGitName != gitName || newGitEmail != gitEmail)
49-
&& !(string.IsNullOrEmpty(newGitName) || string.IsNullOrEmpty(newGitEmail));
52+
if (EditorGUI.EndChangeCheck())
53+
{
54+
needsSaving = !(string.IsNullOrEmpty(newGitName) || string.IsNullOrEmpty(newGitEmail))
55+
&& (newGitName != gitName || newGitEmail != gitEmail);
56+
}
5057

5158
EditorGUI.BeginDisabledGroup(!needsSaving);
5259
{
@@ -55,45 +62,28 @@ public override void OnGUI()
5562
GUI.FocusControl(null);
5663
isBusy = true;
5764

58-
GitClient.SetConfig("user.name", newGitName, GitConfigSource.User)
59-
.Then((success, value) =>
60-
{
65+
GitClient.SetConfigUserAndEmail(newGitName, newGitEmail)
66+
.FinallyInUI((success, exception, user) => {
67+
isBusy = false;
6168
if (success)
6269
{
6370
if (Repository != null)
6471
{
6572
Repository.User.Name = gitName = newGitName;
73+
Repository.User.Email = gitEmail = newGitEmail;
6674
}
6775
else
6876
{
6977
gitName = newGitName;
78+
gitEmail = newGitEmail;
7079
}
80+
81+
needsSaving = false;
82+
83+
Redraw();
84+
Finish(true);
7185
}
7286
})
73-
.Then(
74-
GitClient.SetConfig("user.email", newGitEmail, GitConfigSource.User)
75-
.Then((success, value) =>
76-
{
77-
if (success)
78-
{
79-
if (Repository != null)
80-
{
81-
Repository.User.Email = gitEmail = newGitEmail;
82-
}
83-
else
84-
{
85-
gitEmail = newGitEmail;
86-
}
87-
88-
userDataHasChanged = true;
89-
}
90-
}))
91-
.FinallyInUI((_, __) =>
92-
{
93-
isBusy = false;
94-
Redraw();
95-
Finish(true);
96-
})
9787
.Start();
9888
}
9989
}
@@ -122,6 +112,7 @@ private void MaybeUpdateData()
122112
{
123113
newGitName = gitName = Repository.User.Name;
124114
newGitEmail = gitEmail = Repository.User.Email;
115+
needsSaving = false;
125116
}
126117
}
127118
}
@@ -146,6 +137,7 @@ private void UpdateUserDataFromClient()
146137
{
147138
newGitName = gitName = user.Name;
148139
newGitEmail = gitEmail = user.Email;
140+
needsSaving = false;
149141
Redraw();
150142
}
151143
}).Start();

src/tests/IntegrationTests/Process/ProcessManagerIntegrationTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public async Task LogEntriesTest()
5757
CommitID = "018997938335742f8be694240a7c2b352ec0835f",
5858
Description = "Moving project files where they should be kept",
5959
Summary = "Moving project files where they should be kept",
60-
TimeString = firstCommitTime.ToString(DateTimeFormatInfo.CurrentInfo),
61-
CommitTimeString = firstCommitTime.ToString(DateTimeFormatInfo.CurrentInfo),
60+
TimeString = firstCommitTime.ToString(Constants.Iso8601Format),
61+
CommitTimeString = firstCommitTime.ToString(Constants.Iso8601Format),
6262
},
6363
new GitLogEntry
6464
{
@@ -75,8 +75,8 @@ public async Task LogEntriesTest()
7575
CommitID = "03939ffb3eb8486dba0259b43db00842bbe6eca1",
7676
Description = "Initial Commit",
7777
Summary = "Initial Commit",
78-
TimeString = secondCommitTime.ToString(DateTimeFormatInfo.CurrentInfo),
79-
CommitTimeString = secondCommitTime.ToString(DateTimeFormatInfo.CurrentInfo),
78+
TimeString = secondCommitTime.ToString(Constants.Iso8601Format),
79+
CommitTimeString = secondCommitTime.ToString(Constants.Iso8601Format),
8080
},
8181
});
8282
}
@@ -110,8 +110,8 @@ public async Task RussianLogEntriesTest()
110110
CommitID = "06d6451d351626894a30e9134f551db12c74254b",
111111
Description = "Я люблю github",
112112
Summary = "Я люблю github",
113-
TimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
114-
CommitTimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
113+
TimeString = commitTime.ToString(Constants.Iso8601Format),
114+
CommitTimeString = commitTime.ToString(Constants.Iso8601Format),
115115
}
116116
});
117117
}

src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public void ShouldParseSingleCommit()
5858
},
5959
Summary = "Rename RepositoryModelBase to RepositoryModel",
6060
Description = "Rename RepositoryModelBase to RepositoryModel",
61-
TimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
62-
CommitTimeString = commitTime.ToString(DateTimeFormatInfo.CurrentInfo),
61+
TimeString = commitTime.ToString(Constants.Iso8601Format),
62+
CommitTimeString = commitTime.ToString(Constants.Iso8601Format),
6363
},
6464
};
6565

0 commit comments

Comments
 (0)