Page MenuHomePhabricator

Can not download a specific patch from Gerrit using git-review
Closed, ResolvedPublic

Description

I am on Mac OS. I have tried installing git-review from source (as suggested at T100987#3353888) and from Homebrew (as suggested at Gerrit/git-review#Method_2).

According to git-review/usage.html, this is the way to go: git review -d 781,4

I am trying to download patch 429435, patch set 1 for mediawiki/core.

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ git remote -v
origin	ssh://zfilipin@gerrit.wikimedia.org:29418/mediawiki/core.git (fetch)
origin	ssh://zfilipin@gerrit.wikimedia.org:29418/mediawiki/core.git (push)

When it's installed from source I get this:

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ which git-review
/Users/z/Library/Python/2.7/bin/git-review

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ git-review --version
git-review version 1.26.1.dev2

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ git review -d 429435
Downloading refs/changes/35/429435/5 from gerrit
Branch review/zfilipin/T193244 already exists - reusing
Switched to branch "review/zfilipin/T193244"

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ git review -d 429435,1
Review patchset 429435,1 not found

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ git review -v -d 429435,1
2018-05-11 19:05:25.652650 Running: git config --get gitreview.remote
2018-05-11 19:05:25.658235 result: origin
2018-05-11 19:05:25.658304 Running: git symbolic-ref -q HEAD
2018-05-11 19:05:25.664041 Running: git for-each-ref --format=%(upstream) refs/heads/review/zfilipin/T193244
Following tracked origin/master rather than default origin/master
2018-05-11 19:05:25.670123 Running: git config --get gitreview.scheme
2018-05-11 19:05:25.676312 using default: None
2018-05-11 19:05:25.676381 Running: git config --get gitreview.hostname
2018-05-11 19:05:25.682551 using default: None
2018-05-11 19:05:25.682618 Running: git config --get gitreview.port
2018-05-11 19:05:25.688262 using default: None
2018-05-11 19:05:25.688327 Running: git config --get gitreview.project
2018-05-11 19:05:25.694224 using default: None
2018-05-11 19:05:25.694301 Running: git log --color=never --oneline HEAD^1..HEAD
2018-05-11 19:05:25.702448 Running: git remote
2018-05-11 19:05:25.708407 Running: git branch -a --color=never
2018-05-11 19:05:25.717358 Running: git config --get gitreview.project
2018-05-11 19:05:25.723787 using default: None
2018-05-11 19:05:25.723884 Running: git config --get remote.origin.pushurl
2018-05-11 19:05:25.731335 using default: None
2018-05-11 19:05:25.731397 Running: git config --get remote.origin.url
2018-05-11 19:05:25.738391 result: https://gerrit.wikimedia.org/r/p/mediawiki/core.git
2018-05-11 19:05:25.738462 Running: git config --list
Found origin Push URL: ssh://zfilipin@gerrit.wikimedia.org:29418/mediawiki/core.git
Query gerrit ssh://zfilipin@gerrit.wikimedia.org:29418/mediawiki/core.git --patch-sets change:429435
2018-05-11 19:05:25.746483 Running: ssh -xp29418 zfilipin@gerrit.wikimedia.org gerrit query --format=JSON --patch-sets change:429435
{"project":"mediawiki/core","branch":"master","topic":"T193244","id":"Id06a854b4afb1dd5aba124ff1a3050c9e1065753","number":429435,"subject":"selenium: Do not exclude CirrusSearch when running smoke tests","owner":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"url":"https://gerrit.wikimedia.org/r/429435","commitMessage":"selenium: Do not exclude CirrusSearch when running smoke tests\n\nBug: T193244\nChange-Id: Id06a854b4afb1dd5aba124ff1a3050c9e1065753\n","createdOn":1524842418,"lastUpdated":1525968299,"open":true,"status":"NEW","trackingIds":[{"system":"Bugzilla","id":"193244"},{"system":"Phab","id":"T193244"}],"patchSets":[{"number":1,"revision":"f99071a5462f2dc7ae40adc78a7a6a0eb0d63167","parents":["1c52863fc0c697a7a6216dfe44ca0dd83b6a3408"],"ref":"refs/changes/35/429435/1","uploader":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"createdOn":1524842418,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"REWORK","sizeInsertions":14,"sizeDeletions":-4},{"number":2,"revision":"f7c569e33dea3e19c8c5f5416fd13f28dc14c051","parents":["4f4a620f8e5993f2c1ae8f2afbb999e42ee77471"],"ref":"refs/changes/35/429435/2","uploader":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"createdOn":1525453484,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"REWORK","sizeInsertions":14,"sizeDeletions":0},{"number":3,"revision":"d83908e2626ce3872ab2b5e80d18db182480eb29","parents":["4f4a620f8e5993f2c1ae8f2afbb999e42ee77471"],"ref":"refs/changes/35/429435/3","uploader":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"createdOn":1525454308,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"NO_CODE_CHANGE","sizeInsertions":14,"sizeDeletions":0},{"number":4,"revision":"3de960e3f898888d81ee387dd657384cbbf501fa","parents":["4f4a620f8e5993f2c1ae8f2afbb999e42ee77471"],"ref":"refs/changes/35/429435/4","uploader":{"name":"Krinkle","email":"krinklemail@gmail.com","username":"krinkle"},"createdOn":1525483968,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"REWORK","sizeInsertions":7,"sizeDeletions":0},{"number":5,"revision":"00fa23056f62c154c2ca36dc652d3bad08d1956e","parents":["4f4a620f8e5993f2c1ae8f2afbb999e42ee77471"],"ref":"refs/changes/35/429435/5","uploader":{"name":"Krinkle","email":"krinklemail@gmail.com","username":"krinkle"},"createdOn":1525485827,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"REWORK","sizeInsertions":7,"sizeDeletions":0}]}
{"type":"stats","rowCount":1,"runTimeMilliseconds":15,"moreChanges":false}
Using review info from branch master
Review patchset 429435,1 not found

When installed from Homebrew:

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ which git-review
/usr/local/bin/git-review

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ git-review --version
git-review version 1.26.0

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ git review -d 429435
Downloading refs/changes/35/429435/5 from gerrit
Branch review/zfilipin/T193244 already exists - reusing
Switched to branch "review/zfilipin/T193244"

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ git review -d 429435,1
Review patchset 429435,1 not found

~/Documents/gerrit/mediawiki/vagrant/mediawiki$ git review -v -d 429435,1
2018-05-11 19:14:27.142717 Running: git config --get gitreview.remote
2018-05-11 19:14:27.147690 result: origin
2018-05-11 19:14:27.147756 Running: git symbolic-ref -q HEAD
2018-05-11 19:14:27.152634 Running: git for-each-ref --format=%(upstream) refs/heads/review/zfilipin/T193244
Following tracked origin/master rather than default origin/master
2018-05-11 19:14:27.158499 Running: git config --get gitreview.scheme
2018-05-11 19:14:27.163944 using default: None
2018-05-11 19:14:27.164050 Running: git config --get gitreview.hostname
2018-05-11 19:14:27.169533 using default: None
2018-05-11 19:14:27.169606 Running: git config --get gitreview.port
2018-05-11 19:14:27.175505 using default: None
2018-05-11 19:14:27.175585 Running: git config --get gitreview.project
2018-05-11 19:14:27.181105 using default: None
2018-05-11 19:14:27.181194 Running: git log --color=never --oneline HEAD^1..HEAD
2018-05-11 19:14:27.188667 Running: git remote
2018-05-11 19:14:27.193921 Running: git branch -a --color=never
2018-05-11 19:14:27.201729 Running: git config --get gitreview.project
2018-05-11 19:14:27.207034 using default: None
2018-05-11 19:14:27.207132 Running: git config --get remote.origin.pushurl
2018-05-11 19:14:27.212734 using default: None
2018-05-11 19:14:27.212797 Running: git config --get remote.origin.url
2018-05-11 19:14:27.218299 result: https://gerrit.wikimedia.org/r/p/mediawiki/core.git
2018-05-11 19:14:27.218399 Running: git config --list
Found origin Push URL: ssh://zfilipin@gerrit.wikimedia.org:29418/mediawiki/core.git
Query gerrit ssh://zfilipin@gerrit.wikimedia.org:29418/mediawiki/core.git --patch-sets change:429435
2018-05-11 19:14:27.223908 Running: ssh -xp29418 zfilipin@gerrit.wikimedia.org gerrit query --format=JSON --patch-sets change:429435
{"project":"mediawiki/core","branch":"master","topic":"T193244","id":"Id06a854b4afb1dd5aba124ff1a3050c9e1065753","number":429435,"subject":"selenium: Do not exclude CirrusSearch when running smoke tests","owner":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"url":"https://gerrit.wikimedia.org/r/429435","commitMessage":"selenium: Do not exclude CirrusSearch when running smoke tests\n\nBug: T193244\nChange-Id: Id06a854b4afb1dd5aba124ff1a3050c9e1065753\n","createdOn":1524842418,"lastUpdated":1525968299,"open":true,"status":"NEW","trackingIds":[{"system":"Bugzilla","id":"193244"},{"system":"Phab","id":"T193244"}],"patchSets":[{"number":1,"revision":"f99071a5462f2dc7ae40adc78a7a6a0eb0d63167","parents":["1c52863fc0c697a7a6216dfe44ca0dd83b6a3408"],"ref":"refs/changes/35/429435/1","uploader":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"createdOn":1524842418,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"REWORK","sizeInsertions":14,"sizeDeletions":-4},{"number":2,"revision":"f7c569e33dea3e19c8c5f5416fd13f28dc14c051","parents":["4f4a620f8e5993f2c1ae8f2afbb999e42ee77471"],"ref":"refs/changes/35/429435/2","uploader":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"createdOn":1525453484,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"REWORK","sizeInsertions":14,"sizeDeletions":0},{"number":3,"revision":"d83908e2626ce3872ab2b5e80d18db182480eb29","parents":["4f4a620f8e5993f2c1ae8f2afbb999e42ee77471"],"ref":"refs/changes/35/429435/3","uploader":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"createdOn":1525454308,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"NO_CODE_CHANGE","sizeInsertions":14,"sizeDeletions":0},{"number":4,"revision":"3de960e3f898888d81ee387dd657384cbbf501fa","parents":["4f4a620f8e5993f2c1ae8f2afbb999e42ee77471"],"ref":"refs/changes/35/429435/4","uploader":{"name":"Krinkle","email":"krinklemail@gmail.com","username":"krinkle"},"createdOn":1525483968,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"REWORK","sizeInsertions":7,"sizeDeletions":0},{"number":5,"revision":"00fa23056f62c154c2ca36dc652d3bad08d1956e","parents":["4f4a620f8e5993f2c1ae8f2afbb999e42ee77471"],"ref":"refs/changes/35/429435/5","uploader":{"name":"Krinkle","email":"krinklemail@gmail.com","username":"krinkle"},"createdOn":1525485827,"author":{"name":"Zfilipin","email":"zfilipin@wikimedia.org","username":"zfilipin"},"isDraft":false,"kind":"REWORK","sizeInsertions":7,"sizeDeletions":0}]}
{"type":"stats","rowCount":1,"runTimeMilliseconds":14,"moreChanges":false}
Using review info from branch master
Review patchset 429435,1 not found

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 11 2018, 5:09 PM
zeljkofilipin triaged this task as Low priority.May 11 2018, 5:15 PM
zeljkofilipin updated the task description. (Show Details)
zeljkofilipin added subscribers: hashar, demon.

@hashar, @demon am I doing something wrong? 🤔

I wonder if this always fails when specifying a patchset number, i.e. the ,1 in 777,1.

The relevant part of git-review seems like:

refspec = [ps for ps in review_info['patchSets'] if ps['number'] == patchset_number][0]['ref']

But in the paste above ps['number'] is an integer and patchset_number is determined by splitting input:

def parse_review_number(review):
    parts = review.split(',')
    if len(parts) < 2:
        parts.append(None)
    return parts

For the input 429435,1 that becomes the string 1 and '1' == 1 is False so that list will always be empty.

@thcipriani are you saying the documentation is wrong and that the feature does not work?

demon moved this task from Bugs & stuff to git-review on the Gerrit board.May 15 2018, 9:06 AM

@thcipriani are you saying the documentation is wrong and that the feature does not work?

Yeah, I suppose. There was a gerrit upgrade that had a similar affect in zuul due to this same kind of thing (see T186381). Lots of json from gerrit changed types in the not-too-distant past. I think this may be another instance of that same problem.

Vvjjkkii renamed this task from Can not download a specific patch from Gerrit using git-review to z3caaaaaaa.Jul 1 2018, 1:10 AM
Vvjjkkii raised the priority of this task from Low to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
thcipriani renamed this task from z3caaaaaaa to Can not download a specific patch from Gerrit using git-review.Jul 1 2018, 6:52 PM
thcipriani updated the task description. (Show Details)
CommunityTechBot lowered the priority of this task from High to Low.Jul 5 2018, 6:41 PM
thcipriani closed this task as Resolved.Aug 21 2018, 3:47 PM

This looks to be fixed in upstream master: https://review.openstack.org/#/c/541791/

Closing this task.

Huji reopened this task as Open.EditedAug 28 2019, 1:33 PM
Huji added a subscriber: Huji.

This was fixed in upstream about a year ago, yet on our instance of gerrit for WMF this issue still prevails.

> git review -d 532713,1
Review patchset 532713,1 not found

@Huji that was an issue about git-review not supporting our version of Gerrit. The upstream change has been released with git-review 1.27.0. Which version are you using? (git-review --version).

Huji closed this task as Resolved.Aug 28 2019, 3:52 PM
Huji claimed this task.

Oh, I see. I was using 1.26.0 and now I upgraded to 1.28.0 and things work smoothly.

@Huji great and thank you for the feedback ;-]