|
@@ -152,9 +152,24 @@ namespace Terra.Arbitrator.Services
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ string refSpec;
|
|
|
+
|
|
|
+ using (var tempRepo = new Repository(ProjectRoot))
|
|
|
+ {
|
|
|
+ var currentBranch = tempRepo.Head;
|
|
|
+ if (currentBranch.TrackedBranch == null)
|
|
|
+ {
|
|
|
+ resolve(0);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var branchName = currentBranch.FriendlyName;
|
|
|
+ var remoteName = currentBranch.TrackedBranch.RemoteName;
|
|
|
+ refSpec = $"{branchName}:refs/remotes/{remoteName}/{branchName}";
|
|
|
+ }
|
|
|
+
|
|
|
var authenticatedUrl = GetAuthenticatedRemoteUrl();
|
|
|
var progressReporter = new Progress<string>(line => ParseProgress(line, onProgress));
|
|
|
- await GitCommand.RunGitAsync(new StringBuilder(), new[] { "fetch", authenticatedUrl, "--progress" }, progressReporter);
|
|
|
+ await GitCommand.RunGitAsync(new StringBuilder(), new[] { "fetch", authenticatedUrl, refSpec, "--progress" }, progressReporter);
|
|
|
|
|
|
using var repo = new Repository(ProjectRoot);
|
|
|
resolve(repo.Head.TrackingDetails.BehindBy);
|
|
@@ -248,9 +263,6 @@ namespace Terra.Arbitrator.Services
|
|
|
{
|
|
|
var remote = repo.Network.Remotes["origin"];
|
|
|
if (remote == null) throw new Exception("No remote named 'origin' found.");
|
|
|
-
|
|
|
- var fetchOptions = new FetchOptions { CertificateCheck = (_, _, _) => true };
|
|
|
- Commands.Fetch(repo, remote.Name, Array.Empty<string>(), fetchOptions, "Arbitrator pre-push fetch");
|
|
|
|
|
|
var trackingDetails = repo.Head.TrackingDetails;
|
|
|
if (trackingDetails.BehindBy > 0)
|
|
@@ -436,7 +448,7 @@ namespace Terra.Arbitrator.Services
|
|
|
try
|
|
|
{
|
|
|
using var repo = new Repository(ProjectRoot);
|
|
|
- var result = AnalyzePullConflictsInternal(repo).Result;
|
|
|
+ var result = AnalyzePullConflictsInternal(repo).Result;
|
|
|
resolve(result);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -449,7 +461,6 @@ namespace Terra.Arbitrator.Services
|
|
|
{
|
|
|
var remote = repo.Network.Remotes["origin"];
|
|
|
if (remote == null) throw new Exception("No remote named 'origin' was found.");
|
|
|
- Commands.Fetch(repo, remote.Name, Array.Empty<string>(), new FetchOptions { CertificateCheck = (_,_,_) => true }, null);
|
|
|
|
|
|
var localBranch = repo.Head;
|
|
|
var remoteBranch = repo.Head.TrackedBranch;
|
|
@@ -465,15 +476,22 @@ namespace Terra.Arbitrator.Services
|
|
|
return Task.FromResult(new PullAnalysisResult(ourChanges.Where(theirChanges.Contains).ToList()));
|
|
|
}
|
|
|
|
|
|
- public static void SafePullExecutor(Action<string> resolve, Action<Exception> reject)
|
|
|
+ public static async void SafePullExecutor(Action<string> resolve, Action<Exception> reject)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- using var repo = new Repository(ProjectRoot);
|
|
|
- var signature = new Signature("Better Git Tool", "bettergit@letsterra.com", DateTimeOffset.Now);
|
|
|
- var pullOptions = new PullOptions { FetchOptions = new FetchOptions { CertificateCheck = (_,_,_) => true } };
|
|
|
- var mergeResult = Commands.Pull(repo, signature, pullOptions);
|
|
|
- resolve(mergeResult.Status == MergeStatus.UpToDate ? "Already up-to-date." : $"Pull successful. Status: {mergeResult.Status}");
|
|
|
+ var authenticatedUrl = GetAuthenticatedRemoteUrl();
|
|
|
+ var log = new StringBuilder();
|
|
|
+
|
|
|
+ string currentBranchName;
|
|
|
+ using (var repo = new Repository(ProjectRoot))
|
|
|
+ {
|
|
|
+ currentBranchName = repo.Head.FriendlyName;
|
|
|
+ }
|
|
|
+
|
|
|
+ await GitCommand.RunGitAsync(log, new[] { "pull", "--no-rebase", authenticatedUrl, currentBranchName }, 0, 141);
|
|
|
+
|
|
|
+ resolve(log.ToString());
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|