Skip to content

Commit 7ae8c4e

Browse files
committed
Exclude changes works.
1 parent 6128069 commit 7ae8c4e

File tree

4 files changed

+16
-39
lines changed

4 files changed

+16
-39
lines changed

RetailCoder.VBE/UI/SourceControl/ChangesViewViewModel.cs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public void RefreshView()
5151
{
5252
OnPropertyChanged("CurrentBranch");
5353
OnPropertyChanged("IncludedChanges");
54-
OnPropertyChanged("ExcludedChanges");
5554
OnPropertyChanged("UntrackedFiles");
5655
}
5756

@@ -75,26 +74,17 @@ public IEnumerable<IFileStatusEntry> IncludedChanges
7574
? new ObservableCollection<IFileStatusEntry>()
7675
: new ObservableCollection<IFileStatusEntry>(
7776
Provider.Status()
78-
.Where(
79-
stat =>
80-
stat.FileStatus.HasFlag(FileStatus.Modified) ||
81-
stat.FileStatus.HasFlag(FileStatus.Added)));
77+
.Where(stat =>
78+
(stat.FileStatus.HasFlag(FileStatus.Modified) ||
79+
stat.FileStatus.HasFlag(FileStatus.Added)) &&
80+
!ExcludedChanges.Select(f => f.FilePath).Contains(stat.FilePath)));
8281
}
8382
}
8483

85-
public IEnumerable<IFileStatusEntry> ExcludedChanges
84+
private readonly ObservableCollection<IFileStatusEntry> _excludedChanges = new ObservableCollection<IFileStatusEntry>();
85+
public ObservableCollection<IFileStatusEntry> ExcludedChanges
8686
{
87-
get
88-
{
89-
return Provider == null
90-
? new ObservableCollection<IFileStatusEntry>()
91-
: new ObservableCollection<IFileStatusEntry>(
92-
Provider.Status()
93-
.Where(
94-
stat =>
95-
stat.FileStatus.HasFlag(FileStatus.Ignored) &&
96-
stat.FileStatus.HasFlag(FileStatus.Modified)));
97-
}
87+
get { return _excludedChanges; }
9888
}
9989

10090
public IEnumerable<IFileStatusEntry> UntrackedFiles
@@ -162,14 +152,21 @@ private void Commit()
162152

163153
private void IncludeChanges(IFileStatusEntry fileStatusEntry)
164154
{
165-
Provider.AddFile(fileStatusEntry.FilePath);
155+
if (UntrackedFiles.FirstOrDefault(f => f.FilePath == fileStatusEntry.FilePath) != null)
156+
{
157+
Provider.AddFile(fileStatusEntry.FilePath);
158+
}
159+
else
160+
{
161+
ExcludedChanges.Remove(ExcludedChanges.FirstOrDefault(f => f.FilePath == fileStatusEntry.FilePath));
162+
}
166163

167164
RefreshView();
168165
}
169166

170167
private void ExcludeChanges(IFileStatusEntry fileStatusEntry)
171168
{
172-
Provider.ExcludeFile(fileStatusEntry.FilePath);
169+
ExcludedChanges.Add(fileStatusEntry);
173170

174171
RefreshView();
175172
}

Rubberduck.SourceControl/GitProvider.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -436,19 +436,6 @@ public override void AddFile(string filePath)
436436
}
437437
}
438438

439-
public override void ExcludeFile(string filePath)
440-
{
441-
try
442-
{
443-
// https://github.com/libgit2/libgit2sharp/wiki/Git-add
444-
_repo.Unstage(filePath);
445-
}
446-
catch (LibGit2SharpException ex)
447-
{
448-
throw new SourceControlException(string.Format("Failed to stage file {0}", filePath), ex);
449-
}
450-
}
451-
452439
/// <summary>
453440
/// Removes file from staging area, but leaves the file in the working directory.
454441
/// </summary>

Rubberduck.SourceControl/ISourceControlProvider.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ public interface ISourceControlProvider
108108
/// <param name="filePath"></param>
109109
void AddFile(string filePath);
110110

111-
/// <summary>
112-
/// Exclude a file from tracking.
113-
/// </summary>
114-
/// <param name="filePath">The name of the file to exclude</param>
115-
void ExcludeFile(string filePath);
116-
117111
/// <summary>
118112
/// Removes file from tracking.
119113
/// </summary>

Rubberduck.SourceControl/SourceControlProviderBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ protected SourceControlProviderBase(VBProject project, IRepository repository, I
4242
public abstract void Commit(string message);
4343
public abstract void Publish(string branch);
4444
public abstract void Unpublish(string branch);
45-
public abstract void ExcludeFile(string filePath);
4645

4746
public virtual void CreateBranch(string sourceBranch, string branch)
4847
{

0 commit comments

Comments
 (0)