git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-gui: Modify push dialog to support Gerrit review

From
JEJoergen Edelbo <jed@napatech.com>
Date
Sep 6, 2013, 10:30 UTC
Message-ID
<20130906105022.0718C12156D@jed-dev-01.labnet>
Problem: It is not possible to push for Gerrit review as you will
always try to push to "refs/heads/..." on the remote.
Changes done:

Add an option to select "Gerrit review" and a corresponding entry for a branch name. If this option is selected, push the changes to "refs/for/<gerrit-branch>/<local branch>". In this way the local branch names will be used as topic branches on Gerrit. --- Hi all,

This is a second attempt to support Gerrit review. It is fully backwards compatible as the Gerrit option is an addition only. It is also better than the first approach as it supports pushing more local branches to Gerrit - each having their own topic branch there.

Further improvement could be to make the Gerrit branch specification a drop down list, but I would like to have this first simple approach evaluated first.

BR Joergen
 lib/transport.tcl |   30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/lib/transport.tcl b/lib/transport.tcl
index e5d211e..adf2bbb 100644
--- a/lib/transport.tcl
+++ b/lib/transport.tcl
@@ -61,6 +61,7 @@ proc push_to {remote} {
 
 proc start_push_anywhere_action {w} {
 	global push_urltype push_remote push_url push_thin push_tags
+	global gerrit_review gerrit_branch
 	global push_force
 	global repo_config
 
@@ -95,7 +96,15 @@ proc start_push_anywhere_action {w} {
 		set cnt 0
 		foreach i [$w.source.l curselection] {
 			set b [$w.source.l get $i]
-			lappend cmd "refs/heads/$b:refs/heads/$b"
+			if {$gerrit_review && $gerrit_branch ne {}} {
+				if {$gerrit_branch eq $b} {
+					lappend cmd "refs/heads/$b:refs/for/$b"
+				} else {
+					lappend cmd "refs/heads/$b:refs/for/$gerrit_branch/$b"
+				}
+			} else {
+				lappend cmd "refs/heads/$b:refs/heads/$b"
+			}
 			incr cnt
 		}
 		if {$cnt == 0} {
@@ -120,6 +129,7 @@ trace add variable push_remote write \
 proc do_push_anywhere {} {
 	global all_remotes current_branch
 	global push_urltype push_remote push_url push_thin push_tags
+	global gerrit_review gerrit_branch
 	global push_force use_ttk NS
 
 	set w .push_setup
@@ -215,6 +225,24 @@ proc do_push_anywhere {} {
 		-text [mc "Include tags"] \
 		-variable push_tags
 	grid $w.options.tags -columnspan 2 -sticky w
+	${NS}::checkbutton $w.options.gerrit \
+		-text [mc "Gerrit review.  Branch: "] \
+		-variable gerrit_review
+	${NS}::entry $w.options.gerrit_br \
+		-width 50 \
+		-textvariable gerrit_branch \
+		-validate key \
+		-validatecommand {
+			if {%d == 1 && [regexp {\s} %S]} {return 0}
+			if {%d == 1 && [string length %S] > 0} {
+				set gerrit_review 1
+			}
+			if {[string length %P] == 0} {
+				set gerrit_review 0
+			}
+			return 1
+		}
+	grid $w.options.gerrit $w.options.gerrit_br -sticky we -padx {0 5}
 	grid columnconfigure $w.options 1 -weight 1
 	pack $w.options -anchor nw -fill x -pady 5 -padx 5
 
-- 
1.7.9.5
Next: Phil Hord
Message 1 of 3 in “git-gui: Modify push dialog to support Gerrit review”
  1. git-gui: Modify push dialog to support Gerrit reviewJoergen Edelbo, Sep 6, 2013
  2. Phil HordSep 6, 2013
  3. Jørgen EdelboSep 7, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.