sigma / magit-gh-pulls

Magit plugin for dealing with GitHub pull requests
254 stars 48 forks source link

magit-ph-pulls can't always retrieve commits #109

Open 23RoboticRabbits opened 7 years ago

23RoboticRabbits commented 7 years ago

I've been doing a number of pull-requests reviews for the Greenplum Database (GitHub.com/greenplum-db/gpdb). I noticed that on a number of PRs (e.g PR# 2334) magit-gh-pulls is unable to retrieve the commits for the PR. When I run # f or fetch for that particular PR, mode-line update with connecting to api.github.com and then just hangs. After restart it fails to retrieve anything.

Problem persists after I clear the cache as well a trying on a newly cloned copy of the repository. The pull-requests that fail like this appear to be random.

I'm using SSH to interact with GitHub:

11:14 $ git remote -v
origin  git@github.com:greenplum-db/gpdb (fetch)
origin  git@github.com:greenplum-db/gpdb (push)
matthewbauer commented 7 years ago

I've been having the same issue. One thing to confirm would be that the fetch command actually works outside of magme. For me, at least, it seems to work fine in a shell.

matthewbauer commented 7 years ago

It seems to help setting a token to GitHub for gh.el... Perhaps it has something to do with needing login credentials to download lots of data from GitHub?

eklitzke commented 6 years ago

The problem appears to be related to ssh. I used strace() to debug my emacs that is having the same problem, and it's trying to fetch the other person's repository using SSH:

xxx.10489:execve("/usr/bin/git", ["/usr/bin/git", "--no-pager", "--literal-pathspecs", "-c", "core.preloadindex=true", "-c", "log.showSignature=false", "fetch", "git@github.com:jimpo/bitcoin.git", "wallet-pointer"], 0x7ffc69378f30 /* 62 vars */) = 0

This is incorrect, it should use https:// in this situation.

eklitzke commented 6 years ago

I looked at this more a few days ago, and it looks like magit-gh-pulls always uses the ssh url for pull requests, no matter what:

(defun magit-gh-pulls-fetch-commits ()
  (interactive)
  (magit-section-case
    (unfetched-pull
     (let* ((req (magit-gh-section-req-data))
            (head (oref req :head)))
       (magit-run-git "fetch" (oref (oref head :repo) :ssh-url)
                      (oref head :ref))))
    (pull nil)
    (invalid-pull
     (error "This pull request refers to invalid reference"))))

See that :ssh-url parameter when it runs git fetch? That means that it always tries to fetch the commits for a PR using SSH. This is totally unnecessary since the PR commits are added as refs in the repo, this way:

git fetch origin pull/ID/head:BRANCHNAME

See this GitHub page for details.

sdwolfz commented 6 years ago

Found a workaround by setting magit-gh-pulls-pull-detail-limit to a large number.

(setq magit-gh-pulls-pull-detail-limit 1000)