This repository was archived by the owner on Dec 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +18
-5
lines changed
UnityExtension/Assets/Editor/GitHub.Unity/UI Expand file tree Collapse file tree 4 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ public interface ITreeData
77 {
88 string Path { get ; }
99 bool IsActive { get ; }
10+ bool IsChecked { get ; }
1011 }
1112
1213 [ Serializable ]
@@ -64,6 +65,7 @@ public bool Equals(GitBranchTreeData other)
6465
6566 public string Path => GitBranch . Name ;
6667 public bool IsActive => isActive ;
68+ public bool IsChecked => false ;
6769 }
6870
6971 [ Serializable ]
@@ -73,11 +75,13 @@ public struct GitStatusEntryTreeData : ITreeData
7375
7476 public GitStatusEntry gitStatusEntry ;
7577 public bool isLocked ;
78+ public bool isChecked ;
7679
7780 public GitStatusEntryTreeData ( GitStatusEntry gitStatusEntry , bool isLocked = false )
7881 {
7982 this . isLocked = isLocked ;
8083 this . gitStatusEntry = gitStatusEntry ;
84+ isChecked = gitStatusEntry . Staged ;
8185 }
8286
8387 public override int GetHashCode ( )
@@ -127,5 +131,6 @@ public bool Equals(GitStatusEntryTreeData other)
127131 public GitStatusEntry GitStatusEntry => gitStatusEntry ;
128132 public GitFileStatus FileStatus => gitStatusEntry . Status ;
129133 public bool IsLocked => isLocked ;
134+ public bool IsChecked => isChecked ;
130135 }
131- }
136+ }
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ public void Load(IEnumerable<TData> treeDatas)
118118 {
119119 isActive = treeData . IsActive ;
120120 treeNodeTreeData = treeData ;
121- isChecked = isCheckable && checkedFiles . Contains ( nodePath ) ;
121+ isChecked = isCheckable && ( checkedFiles . Contains ( nodePath ) || treeData . IsChecked ) ;
122122 }
123123
124124 isSelected = selectedNodePath != null && nodePath == selectedNodePath ;
Original file line number Diff line number Diff line change @@ -478,19 +478,26 @@ private void Commit()
478478 {
479479 isBusy = true ;
480480 var files = treeChanges . GetCheckedFiles ( ) . ToList ( ) ;
481- ITask addTask ;
481+ ITask addTask = null ;
482482
483483 if ( files . Count == gitStatusEntries . Count )
484484 {
485485 addTask = Repository . CommitAllFiles ( commitMessage , commitBody ) ;
486486 }
487487 else
488488 {
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 ) ;
490497 }
491498
492499 addTask
493- . FinallyInUI ( ( success , exception ) =>
500+ . FinallyInUI ( ( success , exception ) =>
494501 {
495502 if ( success )
496503 {
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ public struct TestTreeData : ITreeData
3535
3636 public string Path { get ; set ; }
3737 public bool IsActive { get ; set ; }
38+ public bool IsChecked { get ; set ; }
3839
3940 public override string ToString ( )
4041 {
You can’t perform that action at this time.
0 commit comments