Skip to content

Commit

Permalink
Use --repository_url to override the git origin URL
Browse files Browse the repository at this point in the history
This patch allows the user to override the current git repository's origin URL
by setting --repository_url.

We use this where I work with a custom ReviewBoard/Github:FI integration. We
have canonical repos in Github that contributors fork. Contributors work in
their fork while a script on the ReviewBoard server clones the canonical repo
and adds a remote/fetches commits for every fork so that ReviewBoard has access
to all commits.

The repository URL that our integration needs in order to use post-review is the
canonical repo, and not the fork. --repository-url seems like a reasonable entry
point to add this functionality.

In use in our organization by our engineering group.

Reviewed at http://reviews.reviewboard.org/r/2376/
  • Loading branch information
voberoi authored and davidt committed Jul 3, 2011
1 parent 4c9a57e commit d9abc18
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions rbtools/postreview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2813,11 +2813,17 @@ def get_repository_info(self):
if remote and remote != '.' and merge:
self.upstream_branch = '%s/%s' % (remote, merge)

self.upstream_branch, origin_url = self.get_origin(self.upstream_branch,
True)
url = None
if options.repository_url:
url = options.repository_url
else:
self.upstream_branch, origin_url = \
self.get_origin(self.upstream_branch, True)

if not origin_url or origin_url.startswith("fatal:"):
self.upstream_branch, origin_url = self.get_origin()

if not origin_url or origin_url.startswith("fatal:"):
self.upstream_branch, origin_url = self.get_origin()
url = origin_url.rstrip('/')

# Central bare repositories don't have origin URLs.
# We return git_dir instead and hope for the best.
Expand Down Expand Up @@ -3785,7 +3791,9 @@ def parse_options(args):
"outside of a working copy (currently only "
"supported by Subversion with --revision-range or "
"--diff-filename and ClearCase with relative "
"paths outside the view)")
"paths outside the view). For git, this specifies"
"the origin url of the current repository, "
"overriding the origin url supplied by the git client.")
parser.add_option("-d", "--debug",
action="store_true", dest="debug", default=DEBUG,
help="display debug output")
Expand Down

0 comments on commit d9abc18

Please sign in to comment.