Having a gerrit remote means that we fetch changes twice. It's also
not necessary since the push-url can be set on the origin remote. As
a first step, add a config option that changes the default for defaultremote
to origin and then reworks the logic to add the remote url to origin as a
push-url instead of creating a gerrit remote.
Since this will cause people with an existing gerrit remote to have a
push url added and the gerrit remote orpahned, a follow on commit will
come that will look for a gerrit remote and, if it exists, use it as the
source of url for the push-url and then delete the old remote.
Change-Id: Ief5d092a796516de9605b7df64e7b902c3b47351
When looking for candidate topic in bug or blueprint ID, get the
git log without header lines, e.g., commit hash, author, committer,
dates, so that accidental matches such as commit hash (which could look
like a bug ID) or user name (which could look like anything) don't
accidentally get taken as the topic.
Change-Id: Ie45ed7509e7f873e566f078b55cadd547da704dd
Closes-Bug: #2000296
Add the --reviewers argument which allows specifying reviewers to be
added to each patch uploaded. This simplifies the upload process by not
requiring an additional step of adding reviewers to changes.
Gerrit supports specifying reviewers to be added to changes by appending
a list of r='email' options to the refspec being pushed to. For
example, from the Gerrit 'Uploading Changes' documentation:
git push tr:kernel/common HEAD:refs/for/experimental%r=a@a.com,cc=b@o.com
The --reviewers argument can be passed multiple reviewers to add to the
patch set. Reviewers containing whitespace are rejected, as whitespace
cannot be added to the refspec.
Change-Id: I8c2f9453a90dd78aa47f7996f2502f9f6cf2d66d
On test platforms where the default hostname is not an FQDN, git
fails to guess a usable E-mail address. We don't actually care what
E-mail address these tests see, so override it with a known working
value.
Change-Id: Id65af4876b9658c34a10d1a8f5c72813830725c4
It is not clear why git-review might attempt a rebase and fail,
so provide a helpful error message with suggested next steps in
that case.
Co-Authored-By: Clark Boylan <clark.boylan@gmail.com>
Change-Id: I195554ed5c577c39687d9001a177dadf107bab61
Convert to using the requests module which supports proxying of 'https'
connections for retriving the gerrit war file when behind a corporate
proxy.
Change-Id: Id368cb6aa7058970ad6ac10caacea2aec9bfe48b
Git plumbing command rev-parse is able to return the current branch
symbolic name in a machine readable manner and will return the rev
inputted (HEAD in this case) if no corresponding branch can be found
(detached HEAD).
This works on all versions of git since 1.6.3 and alternatively can be
replaced with 'git symbolic-ref --short -q HEAD' on versions 1.7.10 and
newer.
Change-Id: I486dcad4b73f9f06d7196e6888a4da79c7d574ad
Prevent user or system configuration from impacting the output of git
commands through custom configuration options. Example is enabling of
"branch.autosetuprebase=always" will result a different message being
outputted by git when creating branches causing some tests to fail when
attempting to match against the expected output.
Change-Id: Ic6526217b598abfef0a272bc7cd1852c5821163a
There are more things that break if we run git with i18n on. Make sure
that we always set LANG and LANGUAGE to C so that we get predictable
output.
Change-Id: I1bf1124f0b09d6658a7b0703e3b9e74ed80f4eea
Sometimes it's difficult to understand reason
why git review -s failed since error description
in code is not streamed to stdout.
Change-Id: I59c0deef5f32d10f9e3e7c50dbaffc6a9f59a466
Closes-Bug: #2000234
When choosing the branch to submit a changeset against, and
against which to rebase a changeset if it is being rebased, a new
gerrit.track configuration item and corresponding --track command
line option indicate to use the upstream branch being tracked as the
source of branch information, in preference to configuration. When
downloading a changeset, always set it up to track the matching
remote branch to make --track work for downloaded changesets.
If a branch name is provided explicitly on the command line, it
overrides the tracked branch.
Rationale:
Workflows with multiple active branches are common. For example,
there may be one development branch (master) and multiple branches
representing prior releases to which bug fixes are still being
made. Then a common workflow is to fix bugs in the earliest
affected branch still maintained and merge forward or cherry-pick
to master. The commits being made to the earlier released branches
should not be rebased against master.
A typical usage pattern in this workflow is:
git checkout -b my-feature origin/master
... implement feature ...
git review -f
git checkout -b my-bug-fix origin/maintenancebranch
... implement bug fix ...
git review -f maintenancebranch
git checkout -b my-bug-fix-merge origin/master
git merge maintenancebranch / git cherry-pick -x ... / git review -x ...
git review -f
The developer, who is usually implementing features and therefore
used to working against master, may accidentally forget to name
the release branch when running git review for the bug fix to the
release branch. Mananging .gitreview files across branches and
repositories scales poorly with larger numbers of repositories
and branches and can be vulnerable to missed bad merges altering
configuration to point at wrong branches.
This change rebases changesets against the tracked remote and branch,
or if no branch is tracked, against the previously-specified branch,
instead of against <defaultremote>/master, only if gerrit.track has
been set to true. With this change, the developer can safely omit
to specify the branch name when committing changes to non-default
branches such as "maintenancebranch" in the example.
When downloading a changeset, it will always be set up to track the
matching remote branch. That way, whether or not the gerrit.track
configuration item is set when the changeset is downloaded, the right
branch will be chosen when it is submitted if gerrit.track is set
after the changeset is downloaded, or if the --track command line
option is specified.
Closes-Bug: #883176
Story: #883176
Story: #2000176
Change-Id: I25f22b9e3cda38598681d720a2f2ac534baec5a6
As a follow up to https://review.openstack.org/109851, we also need to
respect the "url.<base>.pushInsteadOf" setting like git remote show
did.
Change-Id: I6c4cb9e11dcc5f096af03b2b2356216365eaf111
Authentication could be required when performing REST API authenticated
queries over http(s) (done by run_http_exc). Typically, it appends with
gerrit behind apache2.
This change queries git credential for gerrit password when http request
returns a 401.
Change-Id: Iad60eea938c42210ba8c5df4a1b76f8d2f4dd76d
Currently http errors are raised inside a try bloc and transformed in
a more generic exception. This change raises http errors outside the
try bloc.
Change-Id: Iece270ac84925625e848f3049072f39e19e068cc
The encoding header is semi-invalid has the encoding name should be
"utf-8" and not "utf8", which is not the official name of the encoding
and is not recognized by all tools.
Change-Id: I4db673fe86f643f5e1b3e5135d8b0cb72407253e
Gerrit 2.9 adds the '--all-reviewers' option to 'gerrit query', which
allows testing that reviewers have been successfully added to a patch
set in tests for new reviewer functionality.
Change-Id: I17f37c8fd46578b4a8cbfacee4eb8073972b2eee
Need to override both variations of the no_proxy environment variable
since some tools do not check for the other if one is already defined.
While 'no_proxy' appears to be now the most common convention, it is
safer to set both lower and upper case to the same value when running
unit tests.
Change-Id: I536b6f2711ac70e0a2a45676098fb461ab3b8d33
Use the git config command and provided options to have git detect
whether color support should be enabled or disabled. Additionally ensure
that git-review color support can be controlled separately via the
option 'color.review', while still falling back to 'color.ui' if the app
specific option is not defined.
This will ensure that when piping or redirecting the output that colour
output will be disabled unless color.review, or it's fallback color.ui,
is set to always.
Also by utilizing 'git config', the any config options specified on the
command line that change behaviour will be adhered to. e.g.
git -c color.review=never review -l
Will always output without color enabled.
Change-Id: I8f83ed8623da88e87972109af956331704e15d38
Closes-Bug: #1097961
git-review retrieved the remote URL based on the output of git-config.
However, contrary to the previous implementation based on
git-remote-show, git-config does not expand the URL of the given remote
taking into account any "url.<base>.insteadOf" config setting.
This change adds the necessary circuitry to expand URLs.
It also adds a regression test.
Change-Id: I826251aaf85d1b1e8bb2b4562e4b65025a7091b9
Closes-Bug: #1348634
By using the GitReviewException class and subclasses, the raised exceptions
will be caught in main() and properly handled. One Exception can be
converted to a CommandFailed exception, and the other is simple enough
to not need a subclass of GitReviewException.
Change-Id: Idb02d43fd480ab67493c757fb95431602239a55f
git-review gets its configuration from multiple sources (by priority):
* command line options
* git-config
* options: username, rebase
* with local/global/system config
* git-review config files
* options: scheme, host, port, project, defaultbranch/remote/rebase
* locally using .gitreview
* globally using ~/.config/gitreview/git-review.conf
* system using /etc/git-review/git-review.conf
.gitreview file is commonly provided versioned in the git repo, where
other git-review config files and git-config is done by developers. It
implies for developers multiple places to define local/global/system
configuration options but some can only be changed by updating
.gitreview (scheme/port...) which is under versioning.
This change proposes to use as configuration sources (by priority):
* command line options
* git-config for developer local/global/system config
* options: username, rebase and all .gitreview options
* .gitreview local file for repo provided specific config
and deprecates git-review global/system files in order to reduce
configuration sources and allow to overload .gitreview configuration
without updating it.
Change-Id: I24aba0fa089de57d51a79049d9c192f76d576f69
git-review behavior depends on git local, global and system configs.
tests have the same dependencies against them but only manage git local
config which implies the config expected by tests could not be the real
one because of git global and system configs.
The same trouble concerns gitreview global and system config files.
This change allows to run git-review in local mode (only using git and
gitreview local config files) by defining the environment variable
"GITREVIEW_LOCAL_MODE". This mode is used by tests to isolate them from
git and gitreview global and system configs. Mocking can not be used as
functional tests call not git-review code but git-review system command.
Change-Id: I598a284aec9e55f9618ab026c55ef0435e370d69
Closes-Bug: #1393192
Currently, python -m git_review.cmd wraps git_review.cmd.main call to
handle correctly unicode in python2 where git-review calls directly
git_review.cmd.main. This change embeds the wrapper inside main in
order to align git-review and python -m git_review.cmd behaviors.
Change-Id: I390e2d68b851299c3b07292b89dee8198068e6aa
The option -T/--no-topic disables review with topic (mutually
exclusive with -t/--topic).
It allows to submit:
* a change without your current branch name as topic,
* a change update without updating current topic.
Change-Id: I06309b14246cb455d55c6833ab6adb932995edfa
--force-rebase has no effect if rebase is disabled through git-config
or git-review config files.
This change ensures -F/--force-rebase "wins" over rebase disabled and
-F/--force-rebase becomes mutually exclusive with -R/--no-rebase.
Change-Id: Idd985a6a7a5b1cffa9bed996bb1ea5907e7d0844
If git-review is not run in git repo top-level dir, then the target
path used for scp uses both "/" and "\", and scp fails.
Change-Id: I8ffe163f9e29423b1c19bd54241a526a9843561f
Closes-Bug: #1024073