Skip to content

Commit

Permalink
Use default retry count (5) for locked files
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusHorstmann authored and arturcic committed Feb 7, 2021
1 parent b66ac01 commit 983238b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/GitVersion.Core/Core/GitPreparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private void CreateOrUpdateLocalBranchesFromRemoteTrackingOnes(string remoteName
}
var remoteRefTipId = remoteTrackingReference.ReferenceTargetId;
log.Info($"Updating local ref '{localRef.Name.Canonical}' to point at {remoteRefTipId}.");
new OperationWithExponentialBackoff<LockedFileException>(new ThreadSleep(), log, () => repository.Refs.UpdateTarget(localRef, remoteRefTipId), maxRetries: 6).ExecuteAsync().Wait();
new OperationWithExponentialBackoff<LockedFileException>(new ThreadSleep(), log, () => repository.Refs.UpdateTarget(localRef, remoteRefTipId)).ExecuteAsync().Wait();
continue;
}

Expand Down Expand Up @@ -383,7 +383,7 @@ public void EnsureLocalBranchExistsForCurrentBranch(IRemote remote, string curre
log.Info(isBranch ? $"Updating local branch {referenceName} to point at {repoTip}"
: $"Updating local branch {referenceName} to match ref {currentBranch}");
var localRef = repository.Refs[localCanonicalName];
new OperationWithExponentialBackoff<LockedFileException>(new ThreadSleep(), log, () => repository.Refs.UpdateTarget(localRef, repoTipId), maxRetries: 6).ExecuteAsync().Wait();
new OperationWithExponentialBackoff<LockedFileException>(new ThreadSleep(), log, () => repository.Refs.UpdateTarget(localRef, repoTipId)).ExecuteAsync().Wait();
}

repository.Checkout(localCanonicalName);
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Core/Model/VersionVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static VersionVariables FromJson(string json)

public static VersionVariables FromFile(string filePath, IFileSystem fileSystem, ILog log)
{
var retryOperation = new OperationWithExponentialBackoff<IOException, VersionVariables>(new ThreadSleep(), null, () => FromFileInternal(filePath, fileSystem), maxRetries: 6);
var retryOperation = new OperationWithExponentialBackoff<IOException, VersionVariables>(new ThreadSleep(), null, () => FromFileInternal(filePath, fileSystem));

var versionVariables = retryOperation.ExecuteAsync().Result;
return versionVariables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Execute(VersionVariables variables, OutputContext context)
}
if (gitVersionOptions.Output.Contains(OutputType.File))
{
var retryOperation = new OperationWithExponentialBackoff<IOException>(new ThreadSleep(), log, () => fileSystem.WriteAllText(context.OutputFile, variables.ToString()), maxRetries: 6);
var retryOperation = new OperationWithExponentialBackoff<IOException>(new ThreadSleep(), log, () => fileSystem.WriteAllText(context.OutputFile, variables.ToString()));
retryOperation.ExecuteAsync().Wait();
}
if (gitVersionOptions.Output.Contains(OutputType.Json))
Expand Down
12 changes: 6 additions & 6 deletions src/GitVersion.LibGit2Sharp/Git/GitRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ICommit FindMergeBase(ICommit commit, ICommit otherCommit)
{
var mergeBase = repositoryInstance.ObjectDatabase.FindMergeBase((Commit)commit, (Commit)otherCommit);
return new Commit(mergeBase);
}, 6).ExecuteAsync().Result;
}).ExecuteAsync().Result;
}

public int GetNumberOfUncommittedChanges()
Expand Down Expand Up @@ -91,7 +91,7 @@ public int GetNumberOfUncommittedChanges()
DiffTargets.Index | DiffTargets.WorkingDirectory);
return changes.Count;
}, 6).ExecuteAsync().Result;
}).ExecuteAsync().Result;
}
public void CreateBranchForPullRequestBranch(AuthenticationInfo auth)
{
Expand Down Expand Up @@ -151,7 +151,7 @@ public void CreateBranchForPullRequestBranch(AuthenticationInfo auth)
var message = $"Remote tip '{canonicalName}' from remote '{remote.Url}' doesn't look like a valid pull request.";
throw new WarningException(message);
}
}, 6).ExecuteAsync().Wait();
}).ExecuteAsync().Wait();
}
public void Clone(string sourceUrl, string workdirPath, AuthenticationInfo auth)
{
Expand All @@ -161,7 +161,7 @@ public void Clone(string sourceUrl, string workdirPath, AuthenticationInfo auth)
{
var path = Repository.Clone(sourceUrl, workdirPath, GetCloneOptions(auth));
log.Info($"Returned path after repository clone: {path}");
}, 6).ExecuteAsync().Wait();
}).ExecuteAsync().Wait();
}
catch (LibGit2SharpException ex)
{
Expand All @@ -184,12 +184,12 @@ public void Clone(string sourceUrl, string workdirPath, AuthenticationInfo auth)
}
public void Checkout(string commitOrBranchSpec)
{
new OperationWithExponentialBackoff<LockedFileException>(new ThreadSleep(), log, () => Commands.Checkout(repositoryInstance, commitOrBranchSpec), 6).ExecuteAsync().Wait();
new OperationWithExponentialBackoff<LockedFileException>(new ThreadSleep(), log, () => Commands.Checkout(repositoryInstance, commitOrBranchSpec)).ExecuteAsync().Wait();
}

public void Fetch(string remote, IEnumerable<string> refSpecs, AuthenticationInfo auth, string logMessage)
{
new OperationWithExponentialBackoff<LockedFileException>(new ThreadSleep(), log, () => Commands.Fetch((Repository)repositoryInstance, remote, refSpecs, GetFetchOptions(auth), logMessage), 6).ExecuteAsync().Wait();
new OperationWithExponentialBackoff<LockedFileException>(new ThreadSleep(), log, () => Commands.Fetch((Repository)repositoryInstance, remote, refSpecs, GetFetchOptions(auth), logMessage)).ExecuteAsync().Wait();
}
internal static string Discover(string path) => Repository.Discover(path);

Expand Down

0 comments on commit 983238b

Please sign in to comment.