Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch instead of pull if the working tree isn't tracking remote. #286

Merged
merged 3 commits into from
Jun 21, 2020

Conversation

yoichi
Copy link
Contributor

@yoichi yoichi commented Jun 18, 2020

Problem

I'm using ghq on a git repository. ghq get -u gives an error when I'm on a branch that has not been pushed to the remote.

Proposal

Invoke git fetch instead of git pull in such situation.

How to reproduce

~/ghq/github.com/x-motemen/ghq% git checkout -b local-branch
Switched to a new branch 'local-branch'
~/ghq/github.com/x-motemen/ghq% ghq get -u github.com/x-motemen/ghq
    update /Users/yoichi/ghq/github.com/x-motemen/ghq
       git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=<remote>/<branch> local-branch

     error failed to get "github.com/x-motemen/ghq": /usr/local/bin/git: exit status 1

@coveralls
Copy link

coveralls commented Jun 18, 2020

Pull Request Test Coverage Report for Build 139766044

  • 6 of 8 (75.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.08%) to 85.646%

Changes Missing Coverage Covered Lines Changed/Added Lines %
vcs.go 6 8 75.0%
Totals Coverage Status
Change from base Build 126705609: -0.08%
Covered Lines: 1080
Relevant Lines: 1261

💛 - Coveralls

@yoichi
Copy link
Contributor Author

yoichi commented Jun 18, 2020

After I submit this PR, I found that we can judge the condition with the exit code of git rev-parse @{u}. The code will be simpler since it does not require output parsing.

Note: The 2 conditions are not same when the upstream is set and deleted.

  • git rev-parse @{u} gives an error
  • git status -b gives output like ## master...origin/master [gone]

@yoichi
Copy link
Contributor Author

yoichi commented Jun 18, 2020

@{u} is also a bit better about the range of git versions it supports.

@Songmu
Copy link
Member

Songmu commented Jun 19, 2020

Yes, I also had trouble with this behavior when bundle updating. It's a good fix.

This change looks generally good. I'll check it out later.

@Songmu Songmu merged commit 53175fd into x-motemen:master Jun 21, 2020
Songmu added a commit that referenced this pull request Jun 21, 2020
## [v1.1.2](v1.1.1...v1.1.2) (2020-06-21)

* update deps [#287](#287) ([Songmu](https://github.com/Songmu))
* Fetch instead of pull if the working tree isn't tracking remote. [#286](#286) ([yoichi](https://github.com/yoichi))
* Refactor so that RemoteRepository#VCS can return an error [#285](#285) ([johejo](https://github.com/johejo))
@coveralls
Copy link

coveralls commented Sep 20, 2024

Pull Request Test Coverage Report for Build 139610110

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 9 of 9 (100.0%) changed or added relevant lines in 1 file are covered.
  • 27 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.09%) to 85.636%

Files with Coverage Reduction New Missed Lines %
vcs.go 27 86.83%
Totals Coverage Status
Change from base Build 126705609: -0.09%
Covered Lines: 1091
Relevant Lines: 1274

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants