Last active
December 31, 2015 21:39
-
-
Save ekimekim/8048731 to your computer and use it in GitHub Desktop.
Pulls every change ref from gerrit remote (TODO: configurable remote), and assigns latest patch to refs/changes/CHANGE_ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import sys | |
from subprocess import check_call as cmd | |
from subprocess import check_output as cmd_out | |
from subprocess import CalledProcessError | |
out = cmd_out(['git', 'ls-remote', 'origin']) | |
refs = [line.split("\t") for line in out.strip().split("\n")] | |
changes = {} | |
for commit, ref in refs: | |
if '/changes/' not in ref: continue | |
change_id = ref.split("/")[3] # refs/changes/??/CHANGE_ID/PATCH_NO | |
changes[change_id] = commit | |
fetch_args = [':'.join([commit, "refs/changes/%s" % change_id]) for change_id, commit in changes.items()] | |
cmd(['git', 'fetch', 'origin'] + fetch_args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment