git-hub 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -1,4 +1,2 @@
1
- pkg/
2
1
  *.swp
3
2
  *~
4
- *.gemspec
@@ -0,0 +1,14 @@
1
+ ## 0.1.2 (2009-12-10)
2
+
3
+ * Fixed README typos
4
+ * Better standalone install line
5
+ * Added man page
6
+ * Added `hub help hub`
7
+
8
+ ## 0.1.1 (2009-12-08)
9
+
10
+ * Fixed gem problems
11
+
12
+ ## 0.1.0 (2009-12-08)
13
+
14
+ * First release
data/README.md CHANGED
@@ -25,7 +25,7 @@ Wrapping `git`:
25
25
  Receiving objects: 100% (4005/4005), 785.82 KiB | 129 KiB/s, done.
26
26
  Resolving deltas: 100% (2505/2505), done.
27
27
 
28
- hub requires you have `git` installed and in your path. It also
28
+ hub requires you have `git` installed and in your `$PATH`. It also
29
29
  requires Ruby 1.8.6+ or Ruby 1.9.1+. No other libraries necessary.
30
30
 
31
31
 
@@ -36,17 +36,17 @@ Install
36
36
 
37
37
  `hub` is most easily installed as a standalone script:
38
38
 
39
- curl http://defunkt.github.com/hub/standalone > ~/bin/hub && chmod 0755 !$
39
+ curl -s http://defunkt.github.com/hub/standalone > ~/bin/hub && chmod 755 !#:4
40
40
 
41
- Assuming `~/bin/` is in your path, you're ready to roll:
41
+ Assuming `~/bin/` is in your `$PATH`, you're ready to roll:
42
42
 
43
43
  $ hub version
44
44
  git version 1.6.4.2
45
45
  hub version 0.1.0
46
46
 
47
- ### Rubygems
47
+ ### RubyGems
48
48
 
49
- Though not recommended, `hub` can also be installed as a Rubygem:
49
+ Though not recommended, `hub` can also be installed as a RubyGem:
50
50
 
51
51
  $ gem install git-hub -s http://gemcutter.org/
52
52
 
@@ -110,7 +110,7 @@ superpowers:
110
110
  $ git remote add rtomayko
111
111
  > git remote add rtomayko git://github.com/rtomayko/CURRENT_REPO.git
112
112
 
113
- $ git remote add -p pjhyett
113
+ $ git remote add -p rtomayko
114
114
  > git remote add rtomayko git@github.com:rtomayko/CURRENT_REPO.git
115
115
 
116
116
  ### git init
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ end
11
11
  desc "Launch Kicker (like autotest)"
12
12
  task :kicker do
13
13
  puts "Kicking... (ctrl+c to cancel)"
14
- exec "kicker -e rake test bin"
14
+ exec "kicker -e rake test lib"
15
15
  end
16
16
 
17
17
  desc "Build a gem"
@@ -22,6 +22,11 @@ task :standalone => [ :test, :load_hub ] do
22
22
  Hub::Standalone.save('hub')
23
23
  end
24
24
 
25
+ desc "Build hub manual"
26
+ task 'man' do
27
+ sh "ron -br5 -m --organization=DEFUNKT --manual='Git Manual' man/*.ron"
28
+ end
29
+
25
30
  task :load_hub do
26
31
  $LOAD_PATH.unshift 'lib'
27
32
  require 'hub'
@@ -145,9 +145,13 @@ module Hub
145
145
  # $ hub help
146
146
  # (print improved help text)
147
147
  def help(args)
148
- return if args.size > 1
149
- puts improved_help_text
150
- exit
148
+ if args[1] == 'hub'
149
+ puts hub_manpage
150
+ exit
151
+ elsif args.size == 1
152
+ puts improved_help_text
153
+ exit
154
+ end
151
155
  end
152
156
 
153
157
  # The text print when `hub help` is run, kept in its own method
@@ -198,6 +202,8 @@ help
198
202
  # from the command line.
199
203
  #
200
204
 
205
+ # Either returns the GitHub user as set by git-config(1) or aborts
206
+ # with an error message.
201
207
  def github_user
202
208
  if USER.empty?
203
209
  abort "** No GitHub user set. See #{LGHCONF}"
@@ -206,6 +212,49 @@ help
206
212
  end
207
213
  end
208
214
 
215
+ # Returns the terminal-formatted manpage, ready to be printed to
216
+ # the screen.
217
+ def hub_manpage
218
+ return "** Can't find groff(1)" unless groff?
219
+
220
+ require 'open3'
221
+ out = nil
222
+ Open3.popen3(groff_command) do |stdin, stdout, _|
223
+ stdin.puts hub_raw_manpage
224
+ stdin.close
225
+ out = stdout.read.strip
226
+ end
227
+ out
228
+ end
229
+
230
+ # Returns true if groff is installed and in our path, false if
231
+ # not.
232
+ def groff?
233
+ system("which groff")
234
+ end
235
+
236
+ # The groff command complete with crazy arguments we need to run
237
+ # in order to turn our raw roff (manpage markup) into something
238
+ # readable on the terminal.
239
+ def groff_command
240
+ "groff -Wall -mtty-char -mandoc -Tascii"
241
+ end
242
+
243
+ # Returns the raw hub manpage. If we're not running in standalone
244
+ # mode, it's a file sitting at the root under the `man`
245
+ # directory.
246
+ #
247
+ # If we are running in standalone mode the manpage will be
248
+ # included after the __END__ of the file so we can grab it using
249
+ # DATA.
250
+ def hub_raw_manpage
251
+ if File.exists? file = File.dirname(__FILE__) + '/../../man/hub.1'
252
+ File.read(file)
253
+ else
254
+ DATA.read
255
+ end
256
+ end
257
+
209
258
  # All calls to `puts` in after hooks or commands are paged,
210
259
  # git-style.
211
260
  def puts(*args)
@@ -231,7 +280,7 @@ help
231
280
  # Wait until we have input before we start the pager
232
281
  Kernel.select [STDIN]
233
282
 
234
- pager = ENV['PAGER'] || 'less'
283
+ pager = ENV['PAGER'] || 'less -isr'
235
284
  exec pager rescue exec "/bin/sh", "-c", pager
236
285
  else
237
286
  # Child process
@@ -16,7 +16,8 @@ module Hub
16
16
 
17
17
  premable
18
18
 
19
- POSTAMBLE = "Hub::Runner.execute(*ARGV)"
19
+ POSTAMBLE = "Hub::Runner.execute(*ARGV)\n"
20
+ MANPAGE = "__END__\n#{File.read('man/hub.1')}"
20
21
 
21
22
  def save(filename, path = '.')
22
23
  target = File.join(File.expand_path(path), filename)
@@ -43,6 +44,7 @@ premable
43
44
  end
44
45
 
45
46
  standalone << POSTAMBLE
47
+ standalone << MANPAGE
46
48
  standalone
47
49
  end
48
50
  end
@@ -1,3 +1,3 @@
1
1
  module Hub
2
- Version = '0.1.1'
2
+ Version = '0.1.2'
3
3
  end
@@ -0,0 +1,94 @@
1
+ .\" generated with Ron/v0.3
2
+ .\" http://github.com/rtomayko/ron/
3
+ .
4
+ .TH "HUB" "1" "December 2009" "DEFUNKT" "Git Manual"
5
+ .
6
+ .SH "NAME"
7
+ \fBhub\fR \-\- git + hub = github
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBhub\fR \fICOMMAND\fR \fIOPTIONS\fR
11
+ .
12
+ .br
13
+ \fBhub alias\fR [\fB\-s\fR] \fISHELL\fR
14
+ .
15
+ .P
16
+ \fBgit init \-g\fR \fIOPTIONS\fR
17
+ .
18
+ .br
19
+ \fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[/\fIREPOSITORY\fR] \fIDIRECTORY\fR
20
+ .
21
+ .br
22
+ \fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[/\fIREPOSITORY\fR]
23
+ .
24
+ .SH "DESCRIPTION"
25
+ \fBhub\fR enhances various \fBgit\fR commands with GitHub remote expansion. The
26
+ alias command displays information on configuring your environment:
27
+ .
28
+ .TP
29
+ \fBhub alias\fR [\fB\-s\fR] \fISHELL\fR
30
+ Writes shell aliasing code for \fISHELL\fR (\fBbash\fR, \fBsh\fR, \fBzsh\fR, \fBcsh\fR) to standard output. With the \fB\-s\fR option, the output of
31
+ this command can be evaluated directly within the shell: \fBeval $(hub alias \-s bash)\fR
32
+ .
33
+ .P
34
+ After configuring the alias, the following commands have superpowers:
35
+ .
36
+ .TP
37
+ \fBgit init\fR \fB\-g\fR \fIOPTIONS\fR
38
+ Create a git repository as with git\-init(1) and add remote \fBorigin\fR at
39
+ "git@github.com:\fIUSER\fR/\fIREPOSITORY\fR.git"; \fIUSER\fR is your GitHub username and \fIREPOSITORY\fR is the current working directory's basename.
40
+ .
41
+ .TP
42
+ \fBgit clone\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR] \fIDIRECTORY\fR
43
+ Clone repository "git://github.com/\fIUSER\fR/\fIREPOSITORY\fR.git" into \fIDIRECTORY\fR as with git\-clone(1). When /\fIREPOSITORY\fR is omitted, the
44
+ basename of the current working directory is used. With \fB\-p\fR, use private
45
+ remote "git@github.com:\fIUSER\fR/\fIREPOSITORY\fR.git".
46
+ .
47
+ .TP
48
+ \fBgit remote add\fR [\fB\-p\fR] \fIOPTIONS\fR \fIUSER\fR[\fB/\fR\fIREPOSITORY\fR]
49
+ Add remote "git://github.com/\fIUSER\fR/\fIREPOSITORY\fR.git" as with
50
+ git\-remote(1). When /\fIREPOSITORY\fR is omitted, the basename of the
51
+ current working directory is used. With \fB\-p\fR, use private remote
52
+ "git@github.com:\fIUSER\fR/\fIREPOSITORY\fR.git".
53
+ .
54
+ .TP
55
+ \fBgit help\fR
56
+ Display enhanced git\-help(1).
57
+ .
58
+ .SH "CONFIGURATION"
59
+ Use git\-config(1) to display the currently configured GitHub username:
60
+ .
61
+ .IP "" 4
62
+ .
63
+ .nf
64
+
65
+ $ git config \-\-global github.user
66
+ .
67
+ .fi
68
+ .
69
+ .IP "" 0
70
+ .
71
+ .P
72
+ Or, set the GitHub username with:
73
+ .
74
+ .IP "" 4
75
+ .
76
+ .nf
77
+
78
+ $ git config \-\-global github.user <username>
79
+ .
80
+ .fi
81
+ .
82
+ .IP "" 0
83
+ .
84
+ .P
85
+ See \fIhttp://github.com/guides/local\-github\-config\fR for more information.
86
+ .
87
+ .SH "BUGS"
88
+ \fIhttp://github.com/defunkt/hub/issues\fR
89
+ .
90
+ .SH "AUTHOR"
91
+ Chris Wanstrath :: chris@ozmm.org :: @defunkt
92
+ .
93
+ .SH "SEE ALSO"
94
+ git(1), git\-clone(1), git\-remote(1), git\-init(1),\fIhttp://github.com\fR, \fIhttp://github.com/defunkt/hub\fR
@@ -0,0 +1,70 @@
1
+ hub(1) -- git + hub = github
2
+ ============================
3
+
4
+ ## SYNOPSIS
5
+
6
+ `hub` <COMMAND> <OPTIONS>
7
+ `hub alias` [`-s`] <SHELL>
8
+
9
+ `git init -g` <OPTIONS>
10
+ `git clone` [`-p`] <OPTIONS> <USER>[/<REPOSITORY>] <DIRECTORY>
11
+ `git remote add` [`-p`] <OPTIONS> <USER>[/<REPOSITORY>]
12
+
13
+ ## DESCRIPTION
14
+
15
+ `hub` enhances various `git` commands with GitHub remote expansion. The
16
+ alias command displays information on configuring your environment:
17
+
18
+ * `hub alias` [`-s`] <SHELL>:
19
+ Writes shell aliasing code for <SHELL> (`bash`, `sh`, `zsh`,
20
+ `csh`) to standard output. With the `-s` option, the output of
21
+ this command can be evaluated directly within the shell:
22
+ `eval $(hub alias -s bash)`
23
+
24
+ After configuring the alias, the following commands have superpowers:
25
+
26
+ * `git init` `-g` <OPTIONS>:
27
+ Create a git repository as with git-init(1) and add remote `origin` at
28
+ "git@github.com:<USER>/<REPOSITORY>.git"; <USER> is your GitHub username and
29
+ <REPOSITORY> is the current working directory's basename.
30
+
31
+ * `git clone` [`-p`] <OPTIONS> <USER>[`/`<REPOSITORY>] <DIRECTORY>:
32
+ Clone repository "git://github.com/<USER>/<REPOSITORY>.git" into
33
+ <DIRECTORY> as with git-clone(1). When /<REPOSITORY> is omitted, the
34
+ basename of the current working directory is used. With `-p`, use private
35
+ remote "git@github.com:<USER>/<REPOSITORY>.git".
36
+
37
+ * `git remote add` [`-p`] <OPTIONS> <USER>[`/`<REPOSITORY>]:
38
+ Add remote "git://github.com/<USER>/<REPOSITORY>.git" as with
39
+ git-remote(1). When /<REPOSITORY> is omitted, the basename of the
40
+ current working directory is used. With `-p`, use private remote
41
+ "git@github.com:<USER>/<REPOSITORY>.git".
42
+
43
+ * `git help`:
44
+ Display enhanced git-help(1).
45
+
46
+ ## CONFIGURATION
47
+
48
+ Use git-config(1) to display the currently configured GitHub username:
49
+
50
+ $ git config --global github.user
51
+
52
+ Or, set the GitHub username with:
53
+
54
+ $ git config --global github.user <username>
55
+
56
+ See <http://github.com/guides/local-github-config> for more information.
57
+
58
+ ## BUGS
59
+
60
+ <http://github.com/defunkt/hub/issues>
61
+
62
+ ## AUTHOR
63
+
64
+ Chris Wanstrath :: chris@ozmm.org :: @defunkt
65
+
66
+ ## SEE ALSO
67
+
68
+ git(1), git-clone(1), git-remote(1), git-init(1),
69
+ <http://github.com>,
70
+ <http://github.com/defunkt/hub>
@@ -97,4 +97,23 @@ class HubTest < Test::Unit::TestCase
97
97
  def test_help_by_default
98
98
  assert_equal Hub::Commands.improved_help_text, hub("")
99
99
  end
100
+
101
+ def test_help_hub
102
+ help_manpage = hub("help hub")
103
+ assert_includes "git + hub = github", help_manpage
104
+ assert_includes "Writes shell aliasing code for", help_manpage
105
+ assert_includes "Chris Wanstrath :: chris@ozmm.org", help_manpage
106
+ assert_includes <<-config, help_manpage
107
+ Use git-config(1) to display the currently configured GitHub username:
108
+ config
109
+ end
110
+
111
+ def test_help_hub_no_groff
112
+ help_manpage = hub("help hub") do
113
+ Hub::Commands.class_eval do
114
+ def groff?; false end
115
+ end
116
+ end
117
+ assert_equal "** Can't find groff(1)\n", help_manpage
118
+ end
100
119
  end
@@ -25,11 +25,14 @@ class StandaloneTest < Test::Unit::TestCase
25
25
  assert_includes "Commands", standalone
26
26
  assert_includes ".execute(*ARGV)", standalone
27
27
  assert_not_includes "module Standalone", standalone
28
+
29
+ standalone =~ /__END__\s*(.+)/m
30
+ assert_equal File.read('man/hub.1'), $1
28
31
  end
29
32
 
30
33
  def test_standalone_save
31
34
  Hub::Standalone.save("hub")
32
- assert_equal Hub::Standalone.build + "\n", File.read('./hub')
35
+ assert_equal Hub::Standalone.build, File.read('./hub')
33
36
  end
34
37
 
35
38
  def test_standalone_save_permission_denied
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-08 00:00:00 -08:00
12
+ date: 2009-12-10 00:00:00 -08:00
13
13
  default_executable: hub
14
14
  dependencies: []
15
15
 
@@ -25,6 +25,7 @@ extra_rdoc_files:
25
25
  files:
26
26
  - .gitignore
27
27
  - .kick
28
+ - HISTORY.md
28
29
  - LICENSE
29
30
  - README.md
30
31
  - Rakefile
@@ -35,6 +36,8 @@ files:
35
36
  - lib/hub/runner.rb
36
37
  - lib/hub/standalone.rb
37
38
  - lib/hub/version.rb
39
+ - man/hub.1
40
+ - man/hub.1.ron
38
41
  - test/alias_test.rb
39
42
  - test/helper.rb
40
43
  - test/hub_test.rb