Skip to content

Commit

Permalink
Merge pull request #762 from github-for-unity/fixes/discard-fails
Browse files Browse the repository at this point in the history
Fix discarding when repo path != project path
  • Loading branch information
shana authored May 17, 2018
2 parents 4596bde + 8a36740 commit 403c7c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/GitHub.Api/Application/ApplicationManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void RestartRepository()

repositoryManager?.Dispose();

repositoryManager = Unity.RepositoryManager.CreateInstance(Platform, TaskManager, GitClient, Environment.FileSystem, Environment.RepositoryPath);
repositoryManager = Unity.RepositoryManager.CreateInstance(Platform, TaskManager, GitClient, Environment.RepositoryPath);
repositoryManager.Initialize();
Environment.Repository.Initialize(repositoryManager, TaskManager);
repositoryManager.Start();
Expand Down
16 changes: 7 additions & 9 deletions src/GitHub.Api/Git/RepositoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class RepositoryManager : IRepositoryManager
private readonly IGitConfig config;
private readonly IGitClient gitClient;
private readonly IRepositoryPathConfiguration repositoryPaths;
private readonly IFileSystem fileSystem;
private readonly CancellationToken token;
private readonly IRepositoryWatcher watcher;

Expand All @@ -118,13 +117,12 @@ class RepositoryManager : IRepositoryManager
public event Action<CacheType> DataNeedsRefreshing;

public RepositoryManager(IGitConfig gitConfig,
IRepositoryWatcher repositoryWatcher, IGitClient gitClient,
IFileSystem fileSystem,
IRepositoryWatcher repositoryWatcher,
IGitClient gitClient,
CancellationToken token,
IRepositoryPathConfiguration repositoryPaths)
{
this.repositoryPaths = repositoryPaths;
this.fileSystem = fileSystem;
this.token = token;
this.gitClient = gitClient;
this.watcher = repositoryWatcher;
Expand All @@ -140,7 +138,7 @@ public RepositoryManager(IGitConfig gitConfig,
}

public static RepositoryManager CreateInstance(IPlatform platform, ITaskManager taskManager, IGitClient gitClient,
IFileSystem fileSystem, NPath repositoryRoot)
NPath repositoryRoot)
{
var repositoryPathConfiguration = new RepositoryPathConfiguration(repositoryRoot);
string filePath = repositoryPathConfiguration.DotGitConfig;
Expand All @@ -149,7 +147,7 @@ public static RepositoryManager CreateInstance(IPlatform platform, ITaskManager
var repositoryWatcher = new RepositoryWatcher(platform, repositoryPathConfiguration, taskManager.Token);

return new RepositoryManager(gitConfig, repositoryWatcher,
gitClient, fileSystem,
gitClient,
taskManager.Token, repositoryPathConfiguration);
}

Expand Down Expand Up @@ -302,14 +300,14 @@ public ITask DiscardChanges(GitStatusEntry[] gitStatusEntries)
ActionTask<GitStatusEntry[]> task = null;
task = new ActionTask<GitStatusEntry[]>(token, (_, entries) =>
{
var itemsToDelete = new List<string>();
var itemsToDelete = new List<NPath>();
var itemsToRevert = new List<string>();
foreach (var gitStatusEntry in gitStatusEntries)
{
if (gitStatusEntry.status == GitFileStatus.Added || gitStatusEntry.status == GitFileStatus.Untracked)
{
itemsToDelete.Add(gitStatusEntry.path);
itemsToDelete.Add(gitStatusEntry.path.ToNPath().MakeAbsolute());
}
else
{
Expand All @@ -321,7 +319,7 @@ public ITask DiscardChanges(GitStatusEntry[] gitStatusEntries)
{
foreach (var itemToDelete in itemsToDelete)
{
fileSystem.FileDelete(itemToDelete);
itemToDelete.DeleteIfExists();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/IntegrationTests/BaseIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected IEnvironment InitializePlatformAndEnvironment(NPath repoPath,
DotGitHead = DotGitPath.Combine("HEAD");
DotGitConfig = DotGitPath.Combine("config");

RepositoryManager = GitHub.Unity.RepositoryManager.CreateInstance(Platform, TaskManager, GitClient, Environment.FileSystem, repoPath);
RepositoryManager = GitHub.Unity.RepositoryManager.CreateInstance(Platform, TaskManager, GitClient, repoPath);
RepositoryManager.Initialize();

onRepositoryManagerCreated?.Invoke(RepositoryManager);
Expand Down

0 comments on commit 403c7c2

Please sign in to comment.