Skip to content

Commit

Permalink
Add "compare" command.
Browse files Browse the repository at this point in the history
This command allows you to view a compare view in the browser
from a START to an END commit.

Example:
  hub compare AWESOME_PATCH...MASTER
  • Loading branch information
joshthecoder authored and defunkt committed Apr 11, 2010
1 parent c0010d1 commit 2155deb
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -165,6 +165,20 @@ login" below for details.
$ git browse -p resque
> open https://github.com:YOUR_USER/resque

### git compare

$ git compare refactor
> open http://github.com/CURRENT_REPO/compare/refactor

$ git compare 1.0...1.1
> open http://github.com/CURRENT_REPO/compare/1.0...1.1

$ git compare -u fix
> (http://github.com/CURRENT_REPO/compare/fix)

$ git compare myfork patch
> open http://github.com/myfork/compare/patch

### git help

$ git help
Expand Down
30 changes: 30 additions & 0 deletions lib/hub/commands.rb
Expand Up @@ -232,6 +232,36 @@ def browse(args)
args.push "#{protocol}://github.com/#{user}/#{repo}"
end

# $ hub compare 1.0...fix
# > open http://github.com/CURRENT_REPO/compare/1.0...fix
# $ hub compare refactor
# > open http://github.com/CURRENT_REPO/comapre/refactor
# $ hub compare myfork feature
# > open http://github.com/myfork/REPO/compare/feature
# $ hub compare -u 1.0...2.0
# (Prints the URL for the compare view)
def compare(args)
args.shift
urlOnly = args.delete('-u') ? true : false
range = args.pop
user = args.pop || OWNER

if range and !OWNER.empty?
url = "http://github.com/#{user}/#{REPO}/compare/#{range}"
else
warn "Usage: hub compare [<START>...]<END>"
exit(1)
end

if urlOnly
puts url
exit
else
args.executable = ENV['BROWSER'] || 'open'
args.push url
end
end

# $ hub hub standalone
# Prints the "standalone" version of hub for an easy, memorable
# installation sequence:
Expand Down
20 changes: 20 additions & 0 deletions man/hub.1.ron
Expand Up @@ -58,6 +58,12 @@ alias command displays information on configuring your environment:
page with https. If the repository isn't specified, `browse` opens
the page of the repository found in the current directory.

* `git compare` [`-u`] [<USER>] [<START>...]<END>:
Open a Github compare view page in the system's default web browser.
<START> to <END> are branch names, tag names, or commit SHA1s specifying
the range of history to compare. If <START> is omitted,
the repository's default branch is assumed.

* `git submodule add` [`-p`] <OPTIONS> [<USER>/]<REPOSITORY> <DIRECTORY>:
Submodule repository "git://github.com/<USER>/<REPOSITORY>.git" into
<DIRECTORY> as with git-submodule(1). When <USER>/ is omitted, assumes
Expand Down Expand Up @@ -151,6 +157,20 @@ cloning:
$ git browse -p resque
> open https://github.com:YOUR_USER/resque

### git compare

$ git compare refactor
> open http://github.com/CURRENT_REPO/compare/refactor

$ git compare 1.0...1.1
> open http://github.com/CURRENT_REPO/compare/1.0...1.1

$ git compare -u fix
> (http://github.com/CURRENT_REPO/compare/fix)

$ git compare myfork patch
> open http://github.com/myfork/compare/patch

### git help

$ git help
Expand Down

0 comments on commit 2155deb

Please sign in to comment.