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

Commit 3baf00e

Browse files
author
Steven Kirk
committed
Do a FF-pull when updating PR from same repo.
Fixes #578.
1 parent e0fc71a commit 3baf00e

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ public IObservable<bool> IsCleanForCheckout(ILocalRepositoryModel repository)
9090
return Observable.Return(!repo.RetrieveStatus().IsDirty);
9191
}
9292

93+
public IObservable<Unit> Pull(ILocalRepositoryModel repository)
94+
{
95+
return Observable.Defer(() =>
96+
{
97+
var repo = gitService.GetRepository(repository.LocalPath);
98+
var refspec = string.Format(CultureInfo.InvariantCulture, "{0}:{0}", repo.Head.FriendlyName);
99+
return gitClient.Fetch(repo, "origin", new[] { refspec }).ToObservable();
100+
});
101+
}
102+
93103
public IObservable<Unit> FetchAndCheckout(ILocalRepositoryModel repository, int pullRequestNumber, string localBranchName)
94104
{
95105
return DoFetchAndCheckout(repository, pullRequestNumber, localBranchName).ToObservable();

src/GitHub.App/ViewModels/PullRequestDetailViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ IObservable<Unit> DoCheckout(object unused)
485485
switch (CheckoutMode)
486486
{
487487
case CheckoutMode.NeedsPull:
488-
operation = pullRequestsService.FetchAndCheckout(repository, Number, repository.CurrentBranch.Name);
488+
operation = pullRequestsService.Pull(repository);
489489
break;
490490
case CheckoutMode.Fetch:
491491
operation = pullRequestsService

src/GitHub.Exports.Reactive/Services/IPullRequestService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ IObservable<IPullRequestModel> CreatePullRequest(IRepositoryHost host,
2929
/// <returns></returns>
3030
IObservable<Unit> FetchAndCheckout(ILocalRepositoryModel repository, int pullRequestNumber, string localBranchName);
3131

32+
/// <summary>
33+
/// Carries out a pull on the current branch.
34+
/// </summary>
35+
/// <param name="repository">The repository.</param>
36+
IObservable<Unit> Pull(ILocalRepositoryModel repository);
37+
3238
/// <summary>
3339
/// Calculates the name of a local branch for a pull request avoiding clashes with existing branches.
3440
/// </summary>

0 commit comments

Comments
 (0)