This repository was archived by the owner on Dec 5, 2024. It is now read-only.
File tree 4 files changed +18
-5
lines changed
UnityExtension/Assets/Editor/GitHub.Unity/UI
4 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ public interface ITreeData
7
7
{
8
8
string Path { get ; }
9
9
bool IsActive { get ; }
10
+ bool IsChecked { get ; }
10
11
}
11
12
12
13
[ Serializable ]
@@ -64,6 +65,7 @@ public bool Equals(GitBranchTreeData other)
64
65
65
66
public string Path => GitBranch . Name ;
66
67
public bool IsActive => isActive ;
68
+ public bool IsChecked => false ;
67
69
}
68
70
69
71
[ Serializable ]
@@ -73,11 +75,13 @@ public struct GitStatusEntryTreeData : ITreeData
73
75
74
76
public GitStatusEntry gitStatusEntry ;
75
77
public bool isLocked ;
78
+ public bool isChecked ;
76
79
77
80
public GitStatusEntryTreeData ( GitStatusEntry gitStatusEntry , bool isLocked = false )
78
81
{
79
82
this . isLocked = isLocked ;
80
83
this . gitStatusEntry = gitStatusEntry ;
84
+ isChecked = gitStatusEntry . Staged ;
81
85
}
82
86
83
87
public override int GetHashCode ( )
@@ -127,5 +131,6 @@ public bool Equals(GitStatusEntryTreeData other)
127
131
public GitStatusEntry GitStatusEntry => gitStatusEntry ;
128
132
public GitFileStatus FileStatus => gitStatusEntry . Status ;
129
133
public bool IsLocked => isLocked ;
134
+ public bool IsChecked => isChecked ;
130
135
}
131
- }
136
+ }
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ public void Load(IEnumerable<TData> treeDatas)
118
118
{
119
119
isActive = treeData . IsActive ;
120
120
treeNodeTreeData = treeData ;
121
- isChecked = isCheckable && checkedFiles . Contains ( nodePath ) ;
121
+ isChecked = isCheckable && ( checkedFiles . Contains ( nodePath ) || treeData . IsChecked ) ;
122
122
}
123
123
124
124
isSelected = selectedNodePath != null && nodePath == selectedNodePath ;
Original file line number Diff line number Diff line change @@ -478,19 +478,26 @@ private void Commit()
478
478
{
479
479
isBusy = true ;
480
480
var files = treeChanges . GetCheckedFiles ( ) . ToList ( ) ;
481
- ITask addTask ;
481
+ ITask addTask = null ;
482
482
483
483
if ( files . Count == gitStatusEntries . Count )
484
484
{
485
485
addTask = Repository . CommitAllFiles ( commitMessage , commitBody ) ;
486
486
}
487
487
else
488
488
{
489
- addTask = Repository . CommitFiles ( files , commitMessage , commitBody ) ;
489
+ ITask commit = Repository . CommitFiles ( files , commitMessage , commitBody ) ;
490
+
491
+ // if there are files that have been staged outside of Unity, but they aren't selected for commit, remove them
492
+ // from the index before commiting, otherwise the commit will take them along.
493
+ var filesStagedButNotChecked = gitStatusEntries . Where ( x => x . Staged ) . Select ( x => x . Path ) . Except ( files ) . ToList ( ) ;
494
+ if ( filesStagedButNotChecked . Count > 0 )
495
+ addTask = GitClient . Remove ( filesStagedButNotChecked ) ;
496
+ addTask = addTask == null ? commit : addTask . Then ( commit ) ;
490
497
}
491
498
492
499
addTask
493
- . FinallyInUI ( ( success , exception ) =>
500
+ . FinallyInUI ( ( success , exception ) =>
494
501
{
495
502
if ( success )
496
503
{
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public struct TestTreeData : ITreeData
35
35
36
36
public string Path { get ; set ; }
37
37
public bool IsActive { get ; set ; }
38
+ public bool IsChecked { get ; set ; }
38
39
39
40
public override string ToString ( )
40
41
{
You can’t perform that action at this time.
0 commit comments