Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit e58bcd2

Browse files
committed
Allow NewInWorkdir files when checking out a PR
These might be build or tool artefacts that shouldn't prevent a PR from being checked out.
1 parent 3ef8a8e commit e58bcd2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,22 @@ public IObservable<string> GetPullRequestTemplate(ILocalRepositoryModel reposito
8989
public IObservable<bool> IsWorkingDirectoryClean(ILocalRepositoryModel repository)
9090
{
9191
var repo = gitService.GetRepository(repository.LocalPath);
92-
return Observable.Return(!repo.RetrieveStatus().IsDirty);
92+
var isClean = !IsFilthy(repo.RetrieveStatus());
93+
return Observable.Return(isClean);
94+
}
95+
96+
static bool IsFilthy(RepositoryStatus status)
97+
{
98+
if (status.IsDirty)
99+
{
100+
// This is similar to IsDirty, but also allows NewInWorkdir files
101+
return status.Any(entry =>
102+
entry.State != FileStatus.Ignored &&
103+
entry.State != FileStatus.Unaltered &&
104+
entry.State != FileStatus.NewInWorkdir);
105+
}
106+
107+
return false;
93108
}
94109

95110
public IObservable<Unit> Pull(ILocalRepositoryModel repository)

0 commit comments

Comments
 (0)