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

Commit 2c2e422

Browse files
authored
Merge branch 'master' into fixes/git-path-find-button
2 parents d3cb538 + 6235515 commit 2c2e422

File tree

8 files changed

+197
-152
lines changed

8 files changed

+197
-152
lines changed

GitHub.Unity.sln.DotSettings

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,6 @@
341341
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
342342
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
343343
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
344-
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
344+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
345+
<s:Boolean x:Key="/Default/Environment/UnitTesting/ShadowCopy/@EntryValue">False</s:Boolean>
346+
</wpf:ResourceDictionary>

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Notices
44

5-
From version 0.19 onwards, the location of the plugin has moved to `Assets/Plugins/GitHub`. If you have version 0.18 or lower, you need to delete the `Assets/Editor/GitHub` folder before you install newer versions. You should exit Unity and delete the folder from Explorer/Finder, as Unity will not unload native libraries while it's running.
5+
From version 0.19 onwards, the location of the plugin has moved to `Assets/Plugins/GitHub`. If you have version 0.18 or lower, you need to delete the `Assets/Editor/GitHub` folder before you install newer versions. You should exit Unity and delete the folder from Explorer/Finder, as Unity will not unload native libraries while it's running. Also, remember to update your `.gitignore` file.
66

77
![Build Status](https://ci.appveyor.com/api/projects/status/github/github-for-unity/Unity?branch=master&svg=true)
88

@@ -81,7 +81,11 @@ Once the extension is installed, you can open a command line with the same Git a
8181

8282
### Installation
8383

84-
To install the extension, download the latest package from [the releases page](https://github.com/github-for-unity/Unity/releases) and double click on it.
84+
This extensions needs to be installed (and updated) for each Unity project that you want to version control.
85+
First step is to download the latest package from [the releases page](https://github.com/github-for-unity/Unity/releases);
86+
it will be saved as a file with the extension `.unitypackage`.
87+
To install it, open Unity, then open the project you want to version control, and then double click on the downloaded package.
88+
Alternatively, import the package by clicking Assets, Import Package, Custom Package, then select the downloaded package.
8589

8690
#### Log files
8791

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,52 +126,52 @@ public List<GitBranch> RemoteBranches
126126
}
127127

128128
[Location("views/branches.yaml", LocationAttribute.Location.LibraryFolder)]
129-
sealed class Favourites : ScriptObjectSingleton<Favourites>
129+
sealed class Favorites : ScriptObjectSingleton<Favorites>
130130
{
131-
[SerializeField] private List<string> favouriteBranches;
132-
public List<string> FavouriteBranches
131+
[SerializeField] private List<string> favoriteBranches;
132+
public List<string> FavoriteBranches
133133
{
134134
get
135135
{
136-
if (favouriteBranches == null)
137-
FavouriteBranches = new List<string>();
138-
return favouriteBranches;
136+
if (favoriteBranches == null)
137+
FavoriteBranches = new List<string>();
138+
return favoriteBranches;
139139
}
140140
set
141141
{
142-
favouriteBranches = value;
142+
favoriteBranches = value;
143143
Save(true);
144144
}
145145
}
146146

147-
public void SetFavourite(string branchName)
147+
public void SetFavorite(string branchName)
148148
{
149-
if (FavouriteBranches.Contains(branchName))
149+
if (FavoriteBranches.Contains(branchName))
150150
return;
151-
FavouriteBranches.Add(branchName);
151+
FavoriteBranches.Add(branchName);
152152
Save(true);
153153
}
154154

155-
public void UnsetFavourite(string branchName)
155+
public void UnsetFavorite(string branchName)
156156
{
157-
if (!FavouriteBranches.Contains(branchName))
157+
if (!FavoriteBranches.Contains(branchName))
158158
return;
159-
FavouriteBranches.Remove(branchName);
159+
FavoriteBranches.Remove(branchName);
160160
Save(true);
161161
}
162162

163-
public void ToggleFavourite(string branchName)
163+
public void ToggleFavorite(string branchName)
164164
{
165-
if (FavouriteBranches.Contains(branchName))
166-
FavouriteBranches.Remove(branchName);
165+
if (FavoriteBranches.Contains(branchName))
166+
FavoriteBranches.Remove(branchName);
167167
else
168-
FavouriteBranches.Add(branchName);
168+
FavoriteBranches.Add(branchName);
169169
Save(true);
170170
}
171171

172-
public bool IsFavourite(string branchName)
172+
public bool IsFavorite(string branchName)
173173
{
174-
return FavouriteBranches.Contains(branchName);
174+
return FavoriteBranches.Contains(branchName);
175175
}
176176
}
177177

src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class Styles
8484
private static Texture2D branchIcon,
8585
activeBranchIcon,
8686
trackingBranchIcon,
87-
favouriteIconOn,
88-
favouriteIconOff,
87+
favoriteIconOn,
88+
favoriteIconOff,
8989
smallLogoIcon,
9090
bigLogoIcon,
9191
defaultAssetIcon,
@@ -663,29 +663,29 @@ public static Texture2D TrackingBranchIcon
663663
}
664664
}
665665

666-
public static Texture2D FavouriteIconOn
666+
public static Texture2D FavoriteIconOn
667667
{
668668
get
669669
{
670-
if (favouriteIconOn == null)
670+
if (favoriteIconOn == null)
671671
{
672-
favouriteIconOn = Utility.GetIcon("favorite-branch-indicator.png");
672+
favoriteIconOn = Utility.GetIcon("favorite-branch-indicator.png");
673673
}
674674

675-
return favouriteIconOn;
675+
return favoriteIconOn;
676676
}
677677
}
678678

679-
public static Texture2D FavouriteIconOff
679+
public static Texture2D FavoriteIconOff
680680
{
681681
get
682682
{
683-
if (favouriteIconOff == null)
683+
if (favoriteIconOff == null)
684684
{
685-
favouriteIconOff = FolderIcon;
685+
favoriteIconOff = FolderIcon;
686686
}
687687

688-
return favouriteIconOff;
688+
return favoriteIconOff;
689689
}
690690
}
691691

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

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ class BranchesView : Subview
3838
private bool showLocalBranches = true;
3939
private bool showRemoteBranches = true;
4040

41-
[NonSerialized] private List<BranchTreeNode> favourites = new List<BranchTreeNode>();
41+
[NonSerialized] private List<BranchTreeNode> favorites = new List<BranchTreeNode>();
4242
[NonSerialized] private int listID = -1;
4343
[NonSerialized] private List<GitBranch> newLocalBranches;
4444
[NonSerialized] private BranchTreeNode newNodeSelection;
4545
[NonSerialized] private BranchesMode targetMode;
46+
[NonSerialized] private bool favoritesHasChanged;
4647

4748
[SerializeField] private BranchTreeNode activeBranchNode;
4849
[SerializeField] private BranchTreeNode localRoot;
@@ -51,6 +52,7 @@ class BranchesView : Subview
5152
[SerializeField] private List<Remote> remotes = new List<Remote>();
5253
[SerializeField] private Vector2 scroll;
5354
[SerializeField] private BranchTreeNode selectedNode;
55+
private List<string> favoritesList;
5456

5557
public override void InitializeView(IView parent)
5658
{
@@ -62,6 +64,7 @@ public override void OnEnable()
6264
{
6365
base.OnEnable();
6466
AttachHandlers(Repository);
67+
favoritesHasChanged = true;
6568
}
6669

6770
public override void OnDisable()
@@ -70,6 +73,21 @@ public override void OnDisable()
7073
DetachHandlers(Repository);
7174
}
7275

76+
public override void OnDataUpdate()
77+
{
78+
base.OnDataUpdate();
79+
MaybeUpdateData();
80+
}
81+
82+
private void MaybeUpdateData()
83+
{
84+
if (favoritesHasChanged)
85+
{
86+
favoritesList = Manager.LocalSettings.Get(FavoritesSetting, new List<string>());
87+
favoritesHasChanged = false;
88+
}
89+
}
90+
7391
public override void OnRepositoryChanged(IRepository oldRepository)
7492
{
7593
base.OnRepositoryChanged(oldRepository);
@@ -142,17 +160,17 @@ public void OnEmbeddedGUI()
142160

143161
GUILayout.BeginVertical(Styles.CommitFileAreaStyle);
144162
{
145-
// Favourites list
146-
if (favourites.Count > 0)
163+
// Favorites list
164+
if (favorites.Count > 0)
147165
{
148166
GUILayout.Label(FavoritesTitle);
149167
GUILayout.BeginHorizontal();
150168
{
151169
GUILayout.BeginVertical();
152170
{
153-
for (var index = 0; index < favourites.Count; ++index)
171+
for (var index = 0; index < favorites.Count; ++index)
154172
{
155-
OnTreeNodeGUI(favourites[index]);
173+
OnTreeNodeGUI(favorites[index]);
156174
}
157175
}
158176

@@ -246,12 +264,12 @@ public void OnEmbeddedGUI()
246264

247265
private int CompareBranches(GitBranch a, GitBranch b)
248266
{
249-
if (GetFavourite(a.Name))
267+
if (IsFavorite(a.Name))
250268
{
251269
return -1;
252270
}
253271

254-
if (GetFavourite(b.Name))
272+
if (IsFavorite(b.Name))
255273
{
256274
return 1;
257275
}
@@ -269,19 +287,9 @@ private int CompareBranches(GitBranch a, GitBranch b)
269287
return 0;
270288
}
271289

272-
private bool GetFavourite(BranchTreeNode branch)
273-
{
274-
return GetFavourite(branch.Name);
275-
}
276-
277-
private bool GetFavourite(string branchName)
290+
private bool IsFavorite(string branchName)
278291
{
279-
if (string.IsNullOrEmpty(branchName))
280-
{
281-
return false;
282-
}
283-
284-
return Manager.LocalSettings.Get(FavoritesSetting, new List<string>()).Contains(branchName);
292+
return !String.IsNullOrEmpty(branchName) && favoritesList.Contains(branchName);
285293
}
286294

287295
private void OnLocalBranchesUpdate(IEnumerable<GitBranch> list)
@@ -310,9 +318,8 @@ private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remo
310318
var tracking = new List<KeyValuePair<int, int>>();
311319
var localBranchNodes = new List<BranchTreeNode>();
312320

313-
// Prepare for updated favourites listing
314-
favourites.Clear();
315-
var cachedFavs = Manager.LocalSettings.Get<List<string>>(FavoritesSetting, new List<string>());
321+
// Prepare for updated favorites listing
322+
favorites.Clear();
316323

317324
// Just build directly on the local root, keep track of active branch
318325
localRoot = new BranchTreeNode("", NodeType.Folder, false);
@@ -341,10 +348,10 @@ private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remo
341348
}
342349
}
343350

344-
// Add to favourites
345-
if (cachedFavs.Contains(branch.Name))
351+
// Add to favorites
352+
if (favoritesList.Contains(branch.Name))
346353
{
347-
favourites.Add(node);
354+
favorites.Add(node);
348355
}
349356

350357
// Build into tree
@@ -385,10 +392,10 @@ private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remo
385392
}
386393
}
387394

388-
// Add to favourites
389-
if (cachedFavs.Contains(branch.Name))
395+
// Add to favorites
396+
if (favoritesList.Contains(branch.Name))
390397
{
391-
favourites.Add(node);
398+
favorites.Add(node);
392399
}
393400

394401
// Build on the root of the remote, just like with locals
@@ -423,23 +430,23 @@ private void BuildTree(BranchTreeNode parent, BranchTreeNode child)
423430
BuildTree(folder, child);
424431
}
425432

426-
private void SetFavourite(BranchTreeNode branch, bool favourite)
433+
private void SetFavorite(BranchTreeNode branch, bool favorite)
427434
{
428435
if (string.IsNullOrEmpty(branch.Name))
429436
{
430437
return;
431438
}
432439

433-
if (!favourite)
440+
if (!favorite)
434441
{
435-
favourites.Remove(branch);
436-
Manager.LocalSettings.Set(FavoritesSetting, favourites.Select(x => x.Name).ToList());
442+
favorites.Remove(branch);
443+
Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
437444
}
438445
else
439446
{
440-
favourites.Remove(branch);
441-
favourites.Add(branch);
442-
Manager.LocalSettings.Set(FavoritesSetting, favourites.Select(x => x.Name).ToList());
447+
favorites.Remove(branch);
448+
favorites.Add(branch);
449+
Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
443450
}
444451
}
445452

@@ -582,12 +589,12 @@ private void OnTreeNodeGUI(BranchTreeNode node)
582589
var style = node.Active ? Styles.BoldLabel : Styles.Label;
583590
var rect = GUILayoutUtility.GetRect(content, style, GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight));
584591
var clickRect = new Rect(0f, rect.y, Position.width, rect.height);
585-
var favouriteRect = new Rect(clickRect.xMax - clickRect.height * 2f, clickRect.y, clickRect.height, clickRect.height);
592+
var favoriteRect = new Rect(clickRect.xMax - clickRect.height * 2f, clickRect.y, clickRect.height, clickRect.height);
586593

587594
var selected = selectedNode == node;
588595
var keyboardFocus = GUIUtility.keyboardControl == listID;
589596

590-
// Selection highlight and favourite toggle
597+
// Selection highlight and favorite toggle
591598
if (selected)
592599
{
593600
if (Event.current.type == EventType.Repaint)
@@ -597,22 +604,22 @@ private void OnTreeNodeGUI(BranchTreeNode node)
597604

598605
if (node.Type != NodeType.Folder)
599606
{
600-
var favourite = GetFavourite(node);
607+
var favorite = IsFavorite(node.Name);
601608
if (Event.current.type == EventType.Repaint)
602609
{
603-
GUI.DrawTexture(favouriteRect, favourite ? Styles.FavouriteIconOn : Styles.FavouriteIconOff);
610+
GUI.DrawTexture(favoriteRect, favorite ? Styles.FavoriteIconOn : Styles.FavoriteIconOff);
604611
}
605-
else if (Event.current.type == EventType.MouseDown && favouriteRect.Contains(Event.current.mousePosition))
612+
else if (Event.current.type == EventType.MouseDown && favoriteRect.Contains(Event.current.mousePosition))
606613
{
607-
SetFavourite(node, !favourite);
614+
SetFavorite(node, !favorite);
608615
Event.current.Use();
609616
}
610617
}
611618
}
612-
// Favourite status
613-
else if (Event.current.type == EventType.Repaint && node.Type != NodeType.Folder && GetFavourite(node.Name))
619+
// Favorite status
620+
else if (Event.current.type == EventType.Repaint && node.Type != NodeType.Folder && IsFavorite(node.Name))
614621
{
615-
GUI.DrawTexture(favouriteRect, Styles.FavouriteIconOn);
622+
GUI.DrawTexture(favoriteRect, Styles.FavoriteIconOn);
616623
}
617624

618625
// The actual icon and label

0 commit comments

Comments
 (0)