Skip to content

Commit 9608ef2

Browse files
Skip archived repositories
1 parent 7d98307 commit 9608ef2

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/App.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public async Task Run(Settings settings)
3030

3131
foreach (var repo in repos)
3232
{
33+
if (repo.Archived)
34+
{
35+
_log($"(skipping archived {repo.Name})");
36+
continue;
37+
}
38+
3339
await _sync.SyncRepo(repo, settings, labels);
3440
_log(string.Empty);
3541
}

test/AppTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,25 @@ public async Task SyncsAllReposFound()
3232
await sync.Received(3).SyncRepo(Arg.Any<Repository>(), settings, Arg.Any<IReadOnlyList<Label>>());
3333
}
3434

35+
[Fact]
36+
public async Task SkipsArchivedRepos()
37+
{
38+
//arrange
39+
var sync = Substitute.For<ISynchronizer>();
40+
sync.ValidateAccess().Returns(ValidationResult.Success());
41+
sync.ValidateUser(Arg.Any<Account>()).Returns(ValidationResult.Success());
42+
sync.GetRepositories(Arg.Any<Account>()).Returns(new[] { new Repository(), new Stubs.ArchivedRepository(), new Repository() });
43+
var app = new App(sync, NoOp, NoOp);
44+
45+
var settings = new Settings { Name = "ecoAPM" };
46+
47+
//act
48+
await app.Run(settings);
49+
50+
//assert
51+
await sync.Received(2).SyncRepo(Arg.Any<Repository>(), settings, Arg.Any<IReadOnlyList<Label>>());
52+
}
53+
3554
[Fact]
3655
public async Task ThrowsOnAccessValidationFailure()
3756
{

test/Stubs/ArchivedRepository.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Octokit;
2+
3+
namespace GitHubLabelSync.Tests.Stubs
4+
{
5+
public class ArchivedRepository : Repository
6+
{
7+
public ArchivedRepository()
8+
{
9+
Archived = true;
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)