aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git-codereview/change.go5
-rw-r--r--git-codereview/change_test.go11
-rw-r--r--git-codereview/doc.go3
3 files changed, 19 insertions, 0 deletions
diff --git a/git-codereview/change.go b/git-codereview/change.go
index 045fe9c..3bdcd75 100644
--- a/git-codereview/change.go
+++ b/git-codereview/change.go
@@ -16,12 +16,14 @@ import (
var commitMsg string
var changeAuto bool
var changeQuick bool
+var changeSignoff bool
func cmdChange(args []string) {
// NOTE: New flags should be added to the usage message below as well as doc.go.
flags.StringVar(&commitMsg, "m", "", "specify a commit message")
flags.BoolVar(&changeAuto, "a", false, "add changes to any tracked files")
flags.BoolVar(&changeQuick, "q", false, "do not edit pending commit msg")
+ flags.BoolVar(&changeSignoff, "s", false, "add a Signed-off-by trailer at the end of the commit message")
flags.Parse(args)
if len(flags.Args()) > 1 {
fmt.Fprintf(stderr(), "Usage: %s change %s [-a] [-m msg] [-q] [branch]\n", progName, globalFlags)
@@ -100,6 +102,9 @@ func commitChanges(amend bool) {
if changeAuto {
args = append(args, "-a")
}
+ if changeSignoff {
+ args = append(args, "-s")
+ }
run("git", args...)
}
commit(amend)
diff --git a/git-codereview/change_test.go b/git-codereview/change_test.go
index 3e3ea30..cd0cbcc 100644
--- a/git-codereview/change_test.go
+++ b/git-codereview/change_test.go
@@ -185,3 +185,14 @@ func TestChangeWithMessage(t *testing.T) {
testMain(t, "change", "-m", "foo: some commit message")
testRan(t, "git commit -q --allow-empty -m foo: some commit message")
}
+
+func TestChangeWithSignoff(t *testing.T) {
+ gt := newGitTest(t)
+ defer gt.done()
+
+ testMain(t, "change", "new_branch")
+ // There are no staged changes, hence an empty commit will be created.
+ // Hence we also need a commit message.
+ testMain(t, "change", "-s", "-m", "foo: bar")
+ testRan(t, "git commit -q --allow-empty -m foo: bar -s")
+}
diff --git a/git-codereview/doc.go b/git-codereview/doc.go
index 2b1af88..a74d7d4 100644
--- a/git-codereview/doc.go
+++ b/git-codereview/doc.go
@@ -157,6 +157,9 @@ option is only useful when creating commits (e.g. if there are unstaged
changes). If a commit already exists, it is overwritten. If -q is also
present, -q will be ignored.
+The -s option adds a Signed-off-by trailer at the end of the commit message;
+it is equivalent to the 'git commit' -s option.
+
As a special case, if branchname is a decimal CL number, such as 987, the change
command downloads the latest patch set of that CL from the server and switches to it.
A specific patch set P can be requested by adding /P: 987.2 for patch set 2 of CL 987.