Fetch all active patches from gerrit
This script helps to avoid switching to browser to fetch fresh patchsets from gerrit:
https://gist.github.com/3293907
#!/usr/bin/env tclsh
# GistID: 3293907
#
# USAGE:
#
# 1. put somewhere in the PATH as git-fetch-patches
# and make it executable
# 2. ensure that repository has remote with name 'gerrit'
# 3. execute 'git fetch-patches'
package require json
set remote gerrit
set url [exec git config --get remote.$remote.url]
set parts [split $url {: /}]
set hostname [lindex $parts 3]
set port [lindex $parts 4]
set project [regsub \.git$ [lindex $parts 5] {}]
file delete -force [exec git rev-parse --git-dir]/refs/patches
set refs {}
set query "ssh -p $port $hostname gerrit query --format=JSON --current-patch-set status:open $project"
foreach {line} [exec sh -c $query] {
set change [json::json2dict "{$line}"]
if {[dict exists $change currentPatchSet]} {
lappend refs "+[dict get $change currentPatchSet ref]:refs/patches/[dict get $change number]"
}
}
puts "Found [llength $refs] patches. Fetching..."
exec -ignorestderr sh -c "git fetch $remote $refs"
Written by Sergey Avseyev
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Tcl
Authors
anthonylevings
6.423K
jkirchartz
3.593K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#