Skip to content

Commit

Permalink
Add check for uncommitted changes before staging
Browse files Browse the repository at this point in the history
Ensure that there are changes to commit by checking repository status before staging files. This prevents unnecessary commit attempts when the repository is clean.
  • Loading branch information
torbacz committed Sep 8, 2024
1 parent b6df27f commit bfa60ad
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/DependencyUpdated.Repositories.AzureDevOps/AzureDevOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public void CommitChanges(string repositoryPath, string projectName, string grou
var gitBranchName = CreateGitBranchName(projectName, config.Value.AzureDevOps.BranchName, group);
logger.Information("Commiting {Repository} to branch {Branch}", repositoryPath, gitBranchName);
using var repo = new Repository(repositoryPath);

var changes = repo.RetrieveStatus(new StatusOptions() { IncludeUntracked = true });
if (!changes.IsDirty)
{
logger.Information("Na changes to commit");
return;
}

Commands.Stage(repo, "*");
var author = new Signature(config.Value.AzureDevOps.Username, config.Value.AzureDevOps.Email,
timeProvider.GetUtcNow());
Expand Down

0 comments on commit bfa60ad

Please sign in to comment.