Skip to content

Commit

Permalink
Added cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
devedse committed Aug 8, 2020
1 parent 644aa50 commit 6af6f72
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions WebOptimizationProject/GitHubRepositoryOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,19 @@ public async Task<IEnumerable<string>> ObtainRepositoriesForOwner(string reposit
return orderedPubReposNames;
}



public async Task GoOptimize(long repositoryId, string branchName = null)
public async Task GoOptimize(bool cleanupAfterwards, long repositoryId, string branchName = null)
{
var repositoryInfo = await _gitOctoKitHandler.GitHubClient.Repository.Get(repositoryId);
await GoOptimize(repositoryInfo, branchName);
await GoOptimize(cleanupAfterwards, repositoryInfo, branchName);
}

public async Task GoOptimize(string repositoryOwner, string repositoryName, string branchName = null)
public async Task GoOptimize(bool cleanupAfterwards, string repositoryOwner, string repositoryName, string branchName = null)
{
var repositoryInfo = await _gitOctoKitHandler.GitHubClient.Repository.Get(repositoryOwner, repositoryName);
await GoOptimize(repositoryInfo, branchName);
await GoOptimize(cleanupAfterwards, repositoryInfo, branchName);
}

public async Task GoOptimize(Repository repository, string branchName = null)
public async Task GoOptimize(bool cleanupAfterwards, Repository repository, string branchName = null)
{
var repositoryOwner = repository.Owner.Login;
var repositoryName = repository.Name;
Expand Down Expand Up @@ -155,6 +153,14 @@ public async Task GoOptimize(Repository repository, string branchName = null)
Console.WriteLine();
Console.WriteLine($"{repositoryOwner}/{repositoryName} is optimized :)");
Console.WriteLine();

if (cleanupAfterwards)
{
Console.WriteLine($"Cleaning up local files '{clonedRepo}'...");
Directory.SetCurrentDirectory(dirOfClonedRepos);
Directory.Delete(clonedRepo, true);
Console.WriteLine($"Directory {clonedRepo} removed.");
}
}

private async Task<IEnumerable<OptimizableFile>> GoOptimize(string dir, WopConfig config)
Expand Down

0 comments on commit 6af6f72

Please sign in to comment.