Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
247 changes: 247 additions & 0 deletions git-change.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
.\" Man page generated from reStructuredText.
.
.TH GIT-CHANGE 1 "2013-08-26" "" ""
.SH NAME
git-change \- Git command to create and manage Gerrit changes
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.\" 0.1.0
.
.SH SYNOPSIS
.nf
\fIgit change\fP [create] [<create\-options>]
\fIgit change\fP update [<update\-options>]
\fIgit change\fP rebase
\fIgit change\fP list
\fIgit change\fP submit
\fIgit change\fP download <review>
\fIgit change\fP gc
\fIgit change\fP print [<print\-options>]
.fi
.sp
.SH DESCRIPTION
.sp
Use git\-change to create and manage changes for the \fBGerrit Code
Review\fP [1] tool. The default behavior is to create a new
change. There are subcommands to manage the change at later stages,
including uploading a new patch set, rebasing, and garbage\-collecting
the temporary change branches this command creates.
.SH USAGE
.sp
create [\-r|\-\-reviewers=] [\-\-cc=] [\-b|\-\-bug=] [\-m|\-\-message=] [\-\-topic=] [\-\-skip=] [\-\-fetch] [\-\-switch] [\-\-chain] [\-\-use\-head\-commit] [\-\-merge\-commit] [\-\-draft]
.INDENT 0.0
.INDENT 3.5
Create a new change and upload to Gerrit. Creating a change is the
default operation, so omitting the subcommand causes \fIgit\-change\fP
to behave as if \fIcreate\fP had been specified.
.sp
The files that make up the change must be staged for commit. Those
staged changes will be committed in a new temporary branch meant
to exist locally and exclusively for this change.
.sp
The \fIcreate\fP subcommand performs the following operations:
.INDENT 0.0
.INDENT 3.5
.nf
1. Notes the current tracking branch (the "target" branch)
2. Creates a temporary, local branch (the "change" branch)
3. Commits the staged changes to the change branch
4. Creates a Gerrit code review destined for the target branch
.fi
.sp
.UNINDENT
.UNINDENT
.sp
If there are commits in the target branch not yet merged into its
remote branch prior to step 3 above, a warning will be issued to
explain that continuing would result in multiple new commits being
added to the temporary branch and pushed to Gerrit, resulting in
multiple code reviews, all of which share the reviewers, bug ID,
etc.
.sp
Change branches are named change\-<ID>, where ID is the change ID
generated by the commit\-msg hook that ships with Gerrit. That hook
must be enabled. Note that if the Change\-Id header is not injected
into the commit message for some reason, or if step 4 above fails,
the temporary change branch will be named tmp\-change\-<TS> where TS
is a timestamp of as a floating point number expressed in seconds
since the epoch. In this case the change branch must be manually
deleted and the change creation must be retried.
.UNINDENT
.UNINDENT
.sp
update [\-r|\-\-reviewers=] [\-\-cc=] [\-b|\-\-bug=] [\-\-skip=] [\-\-draft]
.INDENT 0.0
.INDENT 3.5
Update the existing Gerrit change with new changes. Staged changes
will be automatically committed by amending the HEAD commit. The
current branch must be a temporary change branch.
.UNINDENT
.UNINDENT
.sp
rebase
.INDENT 0.0
.INDENT 3.5
Rebase the target and temporary change branches. The current
branch must be a temporary change branch.
.sp
First the target branch (the branch from which the temporary
change branch was created) will be rebased, then the temporary
change branch will be rebased. This subcommand can be used to pull
upstream changes down to both branches to resolve a failed Gerrit
submission due to a path conflict.
.sp
If there are conflicts with either rebase operation, the process
terminates and it is up to the user to resolve the conflicts at
that point and retry.
.UNINDENT
.UNINDENT
.sp
list
.INDENT 0.0
.INDENT 3.5
List all temporary change branches and display a menu to check one
of them out.
.UNINDENT
.UNINDENT
.sp
submit
.INDENT 0.0
.INDENT 3.5
Submit the code review associated with the current change branch
to Gerrit.
.UNINDENT
.UNINDENT
.sp
download <review>
.INDENT 0.0
.INDENT 3.5
Fetch an existing review from Gerrit to a change branch.
.UNINDENT
.UNINDENT
.sp
gc
.INDENT 0.0
.INDENT 3.5
Remove temporary change branches which are fully merged.
.UNINDENT
.UNINDENT
.sp
print [\-r|\-\-reviewers=] [\-\-cc=] [\-b|\-\-bug=]
.INDENT 0.0
.INDENT 3.5
Print the command to push a change to Gerrit. This can be useful
if manaually creating a Gerrit code review is desired.
.UNINDENT
.UNINDENT
.SH OPTIONS
.INDENT 0.0
.TP
.BI \-r \ <addresses>, \ \-\-reviewers\fB= <addresses>
Comma\-separated list of reviewers.
.TP
.BI \-\-cc\fB= <addresses>
Comma\-separated list of addresses to copy on change notification
mails.
.TP
.BI \-b \ <bug\-id>, \ \-\-bug\fB= <bug\-id>
Bug ID to include in the commit message header. This
option causes \fIgit\-change\fP to set the BUG_ID environment
variable to the given ID before invoking \fIgit\-commit\fP so
that a Git hook can add it as a commit message header.
.TP
.BI \-m \ <msg>, \ \-\-message\fB= <msg>
Use the given message as the commit message.
.TP
.BI \-\-topic\fB= <topic>
Tag the change with the given topic name.
.TP
.BI \-\-skip\fB= <checks>
Comma\-separated list of pre\-commit checks to skip. Option
values: tests, whitespace, linelength, pep8, pyflakes,
jslint or all. This option assumes that a pre\-commit hook
runs the checks, and causes \fIgit\-change\fP to set the SKIP
environment variable to the given list of checks before
invoking \fIgit\-commit\fP so that the hook can skip them.
.TP
.B \-\-fetch
Run \fIgit\-fetch\fP so that remote branch is in sync with
the central repository.
.TP
.B \-\-switch
Switch to the temporary change branch after creating it.
.TP
.B \-\-chain
Chain with the previous Gerrit change. Use when this
change depends on the previous one. Current branch must be
a temporary change branch. Implies \-\-switch.
.TP
.B \-\-use\-head\-commit
Use the HEAD commit as the change to push rather than
committing staged changes.
.TP
.B \-\-merge\-commit
Create a change for a merge commit. Implies
\fI\-\-use\-head\-commit\fP. This flag assumes the current branch
is a tracking branch and that the HEAD commit is an
unreviewed merge commit for which a review is being
created. A change branch will be created and \fIgit\-commit
\-\-amend\fP invoked in order to have the commit\-msg hook add
a change ID header. The usual check for unmerged commits
is skipped, so be sure all of the commits being merged
have change ID headers to avoid having Gerrit create a
review for each one. Finally, note that the HEAD (merge)
commit in the original tracking branch is removed after
the change branch is created.
.TP
.B \-\-draft
Create a draft change rather than a public change.
.TP
.BI \-\-remote\fB= <remote>
Name of the remote repository to fetch from and push to.
Defaults to the \fIgit\-change.remote\fP Git config option if
it is set, otherwise \(aqorigin\(aq.
.TP
.BI \-\-gerrit\-ssh\-host\fB= <host>
Name of the Gerrit server hosting the Git repository.
Defaults to the \fIgit\-change.gerrit\-host\fP Git config
option if it is set. Required unless the config
option is set.
.UNINDENT
.SH SEE ALSO
.sp
git(1), git\-commit(1), git\-merge(1), git\-rebase(1), git\-fetch(1), git\-config(1), githooks(1)
.SH NOTES
.INDENT 0.0
.IP 1. 3
Gerrit Code Review: \fI\%http://code.google.com/p/gerrit/\fP
.UNINDENT
.SH AUTHOR
Jacob Hesch <jacob@nextdoor.com>
.\" Generated by docutils manpage writer.
.
14 changes: 11 additions & 3 deletions git-change.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Git command to create and manage Gerrit changes
-----------------------------------------------

.. |date| date::
.. include:: version.rst
.. 0.1.0

:Author: Jacob Hesch <jacob@nextdoor.com>
:Date: |date|
Expand All @@ -22,6 +22,7 @@ SYNOPSIS
| `git change` rebase
| `git change` list
| `git change` submit
| `git change` download <review>
| `git change` gc
| `git change` print [<print-options>]

Expand All @@ -39,7 +40,7 @@ the temporary change branches this command creates.
USAGE
=====

create [-r|--reviewers=] [--cc=] [-b|--bug=] [-m|--message=] [--topic=] [--skip=] [--fetch] [--switch] [--chain] [--use-head-commit] [--merge-commit]
create [-r|--reviewers=] [--cc=] [-b|--bug=] [-m|--message=] [--topic=] [--skip=] [--fetch] [--switch] [--chain] [--use-head-commit] [--merge-commit] [--draft]

Create a new change and upload to Gerrit. Creating a change is the
default operation, so omitting the subcommand causes `git-change`
Expand Down Expand Up @@ -72,7 +73,7 @@ create [-r|--reviewers=] [--cc=] [-b|--bug=] [-m|--message=] [--topic=] [--skip=
since the epoch. In this case the change branch must be manually
deleted and the change creation must be retried.

update [-r|--reviewers=] [--cc=] [-b|--bug=] [--skip=]
update [-r|--reviewers=] [--cc=] [-b|--bug=] [--skip=] [--draft]

Update the existing Gerrit change with new changes. Staged changes
will be automatically committed by amending the HEAD commit. The
Expand Down Expand Up @@ -104,6 +105,10 @@ submit
Submit the code review associated with the current change branch
to Gerrit.

download <review>

Fetch an existing review from Gerrit to a change branch.

gc

Remove temporary change branches which are fully merged.
Expand Down Expand Up @@ -171,6 +176,9 @@ OPTIONS
commit in the original tracking branch is removed after
the change branch is created.

--draft
Create a draft change rather than a public change.

--remote=<remote>
Name of the remote repository to fetch from and push to.
Defaults to the `git-change.remote` Git config option if
Expand Down
6 changes: 4 additions & 2 deletions git_change/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,10 @@ def search_gerrit(query):
"""
results = []
stats = None
response = run_command('ssh %s gerrit query --format=JSON %s' %
(FLAGS['gerrit-ssh-host'].value, query), trap_stdout=True)
ssh_host, _, ssh_port = FLAGS['gerrit-ssh-host'].value.partition(":")
ssh_port = (ssh_port and "-p %s " % ssh_port) or ""
response = run_command('ssh %s%s gerrit query --format=JSON %s' %
(ssh_port, ssh_host, query), trap_stdout=True)
for line in response.split('\n'):
if not line:
continue
Expand Down
Loading