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

Commit 4a94458

Browse files
Merge branch 'master' into fixes/switching-views
2 parents 9171dbb + 743ed7b commit 4a94458

File tree

5 files changed

+44
-141
lines changed

5 files changed

+44
-141
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/Cache/CacheInterfaces.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public interface ILocalConfigBranchDictionary : IDictionary<string, ConfigBranch
6262

6363
}
6464

65-
public interface IRemoteConfigBranchDictionary : IDictionary<string, IDictionary<string, ConfigBranch>>
65+
public interface IRemoteConfigBranchDictionary : IDictionary<string, Dictionary<string, ConfigBranch>>
6666
{
6767

6868
}

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/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs

Lines changed: 2 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -310,106 +310,6 @@ public void OnAfterDeserialize()
310310
Add(remote, branchesDictionary);
311311
}
312312
}
313-
314-
IEnumerator<KeyValuePair<string, IDictionary<string, ConfigBranch>>> IEnumerable<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.GetEnumerator()
315-
{
316-
throw new NotImplementedException();
317-
//return AsDictionary
318-
// .Select(pair => new KeyValuePair<string, IDictionary<string, ConfigBranch>>(pair.Key, pair.Value.AsDictionary))
319-
// .GetEnumerator();
320-
}
321-
322-
void ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.Add(KeyValuePair<string, IDictionary<string, ConfigBranch>> item)
323-
{
324-
throw new NotImplementedException();
325-
//Guard.ArgumentNotNull(item, "item");
326-
//Guard.ArgumentNotNull(item.Value, "item.Value");
327-
//
328-
//var serializableDictionary = item.Value as SerializableDictionary<string, ConfigBranch>;
329-
//if (serializableDictionary == null)
330-
//{
331-
// serializableDictionary = new SerializableDictionary<string, ConfigBranch>(item.Value);
332-
//}
333-
//
334-
//Add(item.Key, serializableDictionary);
335-
}
336-
337-
bool ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.Contains(KeyValuePair<string, IDictionary<string, ConfigBranch>> item)
338-
{
339-
throw new NotImplementedException();
340-
}
341-
342-
void ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.CopyTo(KeyValuePair<string, IDictionary<string, ConfigBranch>>[] array, int arrayIndex)
343-
{
344-
throw new NotImplementedException();
345-
}
346-
347-
bool ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.Remove(KeyValuePair<string, IDictionary<string, ConfigBranch>> item)
348-
{
349-
throw new NotImplementedException();
350-
}
351-
352-
bool ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.IsReadOnly
353-
{
354-
get { throw new NotImplementedException(); }
355-
}
356-
357-
void IDictionary<string, IDictionary<string, ConfigBranch>>.Add(string key, IDictionary<string, ConfigBranch> value)
358-
{
359-
throw new NotImplementedException();
360-
}
361-
362-
bool IDictionary<string, IDictionary<string, ConfigBranch>>.TryGetValue(string key, out IDictionary<string, ConfigBranch> value)
363-
{
364-
value = null;
365-
366-
Dictionary<string, ConfigBranch> branches;
367-
if (TryGetValue(key, out branches))
368-
{
369-
value = branches;
370-
return true;
371-
}
372-
373-
return false;
374-
}
375-
376-
IDictionary<string, ConfigBranch> IDictionary<string, IDictionary<string, ConfigBranch>>.this[string key]
377-
{
378-
get
379-
{
380-
throw new NotImplementedException();
381-
//var dictionary = (IDictionary<string, IDictionary<string, ConfigBranch>>)this;
382-
//IDictionary<string, ConfigBranch> value;
383-
//if (!dictionary.TryGetValue(key, out value))
384-
//{
385-
// throw new KeyNotFoundException();
386-
//}
387-
//
388-
//return value;
389-
}
390-
set
391-
{
392-
throw new NotImplementedException();
393-
//var dictionary = (IDictionary<string, IDictionary<string, ConfigBranch>>)this;
394-
//dictionary.Add(key, value);
395-
}
396-
}
397-
398-
ICollection<string> IDictionary<string, IDictionary<string, ConfigBranch>>.Keys
399-
{
400-
get
401-
{
402-
throw new NotImplementedException();
403-
}
404-
}
405-
406-
ICollection<IDictionary<string, ConfigBranch>> IDictionary<string, IDictionary<string, ConfigBranch>>.Values
407-
{
408-
get
409-
{
410-
return Values.Cast<IDictionary<string,ConfigBranch>>().ToArray();
411-
}
412-
}
413313
}
414314

415315
[Serializable]
@@ -683,7 +583,7 @@ public void AddLocalBranch(string branch)
683583

684584
public void AddRemoteBranch(string remote, string branch)
685585
{
686-
IDictionary<string, ConfigBranch> branchList;
586+
Dictionary<string, ConfigBranch> branchList;
687587
if (RemoteConfigBranches.TryGetValue(remote, out branchList))
688588
{
689589
if (!branchList.ContainsKey(branch))
@@ -706,7 +606,7 @@ public void AddRemoteBranch(string remote, string branch)
706606

707607
public void RemoveRemoteBranch(string remote, string branch)
708608
{
709-
IDictionary<string, ConfigBranch> branchList;
609+
Dictionary<string, ConfigBranch> branchList;
710610
if (RemoteConfigBranches.TryGetValue(remote, out branchList))
711611
{
712612
if (branchList.ContainsKey(branch))

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();

0 commit comments

Comments
 (0)