提交 d044e078 编写于 作者: M Mislav Marohnić

Merge pull request #605 from github/rubyless-docs

Remove Ruby-specific parts of docs in prep for move to Go
Contributing to hub
===================
<i>**Warning:** in the near future, hub might be implemented
[entirely in Go instead of Ruby](https://github.com/github/hub/issues/475).
Keep that in mind, and don't contribute big features/refactorings to
the Ruby codebase, as such pull requests will be unlikely to get accepted.</i>
You will need:
1. Ruby 1.8.7+
1. Go 1.3
1. Ruby 1.9+
2. git 1.8+
3. tmux & zsh (optional) - for running shell completion tests
## What makes a good hub feature
hub is a tool that wraps git to provide useful integration with GitHub. A new
feature is a good idea for hub only if it relates to *both git and GitHub*.
feature is a good idea for hub if it improves some workflow for a GitHub user.
* A feature that adds GitHub Issues management is **not** a good fit for hub
since it's not git-related. Please use [ghi](https://github.com/stephencelis/ghi)
instead.
* A feature that encapsulates a git workflow *not specific* to GitHub is **not**
a good fit for hub, since something like that is best implemented as an
external script.
......@@ -34,10 +27,8 @@ These instructions assume that _you already have hub installed_ and aliased as
1. Clone hub:
`git clone github/hub && cd hub`
1. Ensure Bundler is installed:
`which bundle || gem install bundler`
1. Install development dependencies:
`bundle install`
1. Install necessary development dependencies:
`script/bootstrap`
2. Verify that existing tests pass:
`script/test`
3. Create a topic branch:
......@@ -53,32 +44,8 @@ These instructions assume that _you already have hub installed_ and aliased as
8. Open a pull request describing your changes:
`git pull-request`
## How hub works
1. [Runner](lib/hub/runner.rb#files) handles the command-line invocation;
2. [Args](lib/hub/args.rb#files) wraps ARGV for easy access;
3. [Commands](lib/hub/commands.rb#files) dispatches each command to the
appropriate method, e.g. `hub pull-request` runs the `pull_request`
method. Each method processes args as needed, using Context and GitHubAPI
in the process;
4. [Context](lib/hub/context.rb#files) handles inspecting the current
environment and git repository;
5. [GitHubAPI](lib/hub/github_api.rb#files) handles GitHub API authentication
and communication;
6. And finally, Runner receives the resulting arguments to execute in the
shell by forwarding them to `git`.
## How to write tests
The old test suite for hub was written in test/unit and some legacy tests can
still be found in the `test/` directory. Unless you have a need for writing
super-isolated unit tests, **do not add** any more tests to this suite.
The new test suite is written in Cucumber under `features/` directory. Each
scenario is actually making real invocations to `hub` on the command-line in the
context of a real (dynamically created) git repository.
......
......@@ -21,7 +21,6 @@ Installation
Dependencies:
* **git 1.7.3** or newer
* **Ruby 1.8.6** or newer
### Homebrew
......@@ -31,20 +30,6 @@ Installing on OS X is easiest with Homebrew:
$ brew install hub
~~~
### `rake install` from source
This is the preferred installation method when no package manager that
supports hub is available:
~~~ sh
# Download or clone the project from GitHub:
$ git clone git://github.com/github/hub.git
$ cd hub
$ rake install
~~~
On a Unix-based OS, this installs under `PREFIX`, which is `/usr/local` by default.
Now you should be ready to roll:
~~~ sh
......@@ -53,77 +38,6 @@ git version 1.7.6
hub version 1.8.3
~~~
#### Windows "Git Bash" (msysGit) note
Avoid aliasing hub as `git` due to the fact that msysGit automatically
configures your prompt to include git information, and you want to avoid slowing
that down. See [Is your shell prompt slow?](#is-your-shell-prompt-slow)
### RubyGems
Though not recommended, hub can also be installed as a RubyGem:
~~~ sh
$ gem install hub
~~~
(It's not recommended for casual use because of the RubyGems startup
time. See [this gist][speed] for information.)
#### Standalone via RubyGems
~~~ sh
$ gem install hub
$ hub hub standalone > ~/bin/hub && chmod +x ~/bin/hub
~~~
This installs a standalone version which doesn't require RubyGems to
run, so it's faster.
### Help! It's slow!
#### Is `hub` noticeably slower than plain git?
That is inconvenient, especially if you want to alias hub as `git`. Few things
you can try:
* Find out which ruby is used for the hub executable:
``` sh
head -1 `which hub`
```
* That ruby should be speedy. Time it with:
``` sh
time /usr/bin/ruby -e0
#=> it should be below 0.01 s total
```
* Check that Ruby isn't loading something shady:
``` sh
echo $RUBYOPT
```
* Check your [GC settings][gc]
General recommendation: you should change hub's shebang line to run with system
ruby (usually `/usr/bin/ruby`) instead of currently active ruby (`/usr/bin/env
ruby`). Also, Ruby 1.8 is speedier than 1.9.
#### Is your shell prompt slow?
Does your prompt show git information? Hub may be slowing down your prompt.
This can happen if you've aliased hub as `git`. This is fine when you use `git`
manually, but may be unacceptable for your prompt, which doesn't need hub
features anyway!
The solution is to identify which shell functions are calling `git`, and replace
each occurrence of that with `command git`. This is a shell feature that enables
you to call a command directly and skip aliases and functions wrapping it.
Aliasing
--------
......@@ -369,7 +283,6 @@ Meta
* Home: <https://github.com/github/hub>
* Bugs: <https://github.com/github/hub/issues>
* Gem: <https://rubygems.org/gems/hub>
* Authors: <https://github.com/github/hub/contributors>
### Prior art
......@@ -377,9 +290,6 @@ Meta
These projects also aim to either improve git or make interacting with
GitHub simpler:
* [hub in Ruby](https://github.com/github/hub/tree/1.12-stable) (previous implementation)
* [eg](http://www.gnome.org/~newren/eg/)
* [github-gem](https://github.com/defunkt/github-gem)
[speed]: http://gist.github.com/284823
[gc]: https://twitter.com/brynary/status/49560668994674688
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册