Skip to content

Commit ade7ae1

Browse files
committed
Add man page
1 parent 170159c commit ade7ae1

File tree

5 files changed

+146
-38
lines changed

5 files changed

+146
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
sandboxrepo
3+
git-open.1

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ script:
1717
- npm run lint:package
1818
- npm run lint:readme
1919
- npm run lint:editorconfig
20+
- npm run lint:man
2021
- shellcheck git-open
22+
- npm run man
2123
- ./bats/bin/bats test/*.bats

README.md

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -105,43 +105,7 @@ git-open can automatically guess the corresponding repository page for remotes
105105
106106
## Configuration
107107
108-
### Configuring the web destination (aka GitLab support)
109-
110-
To configure GitLab support (or other unique hosting situations) you need to set some options.
111-
112-
| option name | description |
113-
| ------------------------- | ---------------- |
114-
| open.[gitdomain].domain | The (web) domain to open based on the provided git repo domain |
115-
| open.[gitdomain].protocol | The (web) protocol to open based on the provided git repo domain. (Defaults to `https`) |
116-
117-
118-
```sh
119-
git config [--global] open.[gitdomain].domain [value]
120-
git config [--global] open.[gitdomain].protocol [value]
121-
```
122-
123-
**Example**
124-
* Your git remote is at `ssh://[email protected]:7000/XXX/YYY.git`
125-
* Your hosted gitlab is `http://repo.intranet/subpath/XXX/YYY`
126-
127-
```sh
128-
git config [--global] "open.https://git.internal.biz.domain" "repo.intranet/subpath"
129-
git config [--global] "open.https://git.internal.biz.protocol" "http"
130-
```
131-
132-
### Configuring which remote to open
133-
134-
By default, `git open` opens the remote named `origin`. However, if your current branch is [remotely-tracking](https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches#_tracking_branches) a different remote, that tracked remote will be used.
135-
136-
In some instances, you may want to override this behavior. When you fork a project
137-
and add a remote named `upstream` you often want that upstream to be opened
138-
rather than your fork. To accomplish this, you can set the `open.default.remote` within your project:
139-
140-
```sh
141-
git config open.default.remote upstream
142-
```
143-
144-
This is equivalent to always typing `git open upstream`.
108+
See the [man page](git-open.1.md) for more information on how to configure `git-open`.
145109
146110
## Alternative projects
147111

git-open.1.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# git-open - Open the repository's website in your browser.
2+
3+
4+
## SYNOPSIS
5+
6+
`git-open` [remote-name] [branch-name]
7+
8+
`git-open` --issue
9+
10+
11+
## DESCRIPTION
12+
13+
`git-open` opens the repository's website in your browser. The major well known
14+
git hosting services are supported.
15+
16+
17+
## OPTIONS
18+
19+
20+
`-i`, `--issue`
21+
Open the current issue. When the name of the current branch matches the right pattern,
22+
it will open the webpage with that issue. See `EXAMPLES` for more information.
23+
This only works on GitHub, GitLab, Visual Studio Team Services and Team Foundation Server at the moment.
24+
25+
`-h`
26+
Show a short help text.
27+
28+
29+
## EXAMPLES
30+
31+
```sh
32+
$ git open
33+
```
34+
35+
It opens https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/
36+
37+
```sh
38+
$ git open someremote
39+
```
40+
41+
It opens https://github.com/PROVIDED_REMOTE_USER/CURRENT_REPO/
42+
43+
```sh
44+
$ git open someremote somebranch
45+
```
46+
47+
It opens https://github.com/PROVIDED_REMOTE_USER/CURRENT_REPO/tree/PROVIDED_BRANCH
48+
49+
```sh
50+
$ git open --issue
51+
```
52+
53+
If branches use naming convention of `issues/#123`, it opens
54+
https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/issues/123
55+
56+
57+
## SUPPORTED REMOTE REPOSITORIES
58+
59+
git-open can automatically guess the corresponding repository page for remotes
60+
(default looks for `origin`) on the following hosts:
61+
62+
- github.com
63+
- gist.github.com
64+
- gitlab.com
65+
- GitLab CE/EE (self hosted GitLab, see `CONFIGURATION`)
66+
- bitbucket.org
67+
- Atlassian Bitbucket Server (formerly _Atlassian Stash_)
68+
- Visual Studio Team Services
69+
- Team Foundation Server (on-premises)
70+
71+
72+
## CONFIGURATION
73+
74+
To configure git-open you may need to set some `git config` options.
75+
You can use `--global` to set across all repos, instead of just the local one.
76+
77+
```sh
78+
$ git config [--global] option value
79+
```
80+
81+
### Configuring which remote to open
82+
83+
By default, `git open` opens the remote named `origin`. However, if your current branch is remotely-tracking a different remote, that tracked remote will be used.
84+
85+
In some instances, you may want to override this behavior. When you fork a project
86+
and add a remote named `upstream` you often want that upstream to be opened
87+
rather than your fork. To accomplish this, you can set the `open.default.remote` within your project:
88+
89+
```sh
90+
git config open.default.remote upstream
91+
```
92+
93+
This is equivalent to always typing `git open upstream`.
94+
95+
96+
### GitLab options
97+
98+
To configure GitLab support (or other unique hosting situations) you may need to set some options.
99+
100+
`open.[gitdomain].domain`
101+
The (web) domain to open based on the provided git repo domain.
102+
103+
`open.[gitdomain].protocol`
104+
The (web) protocol to open based on the provided git repo domain. Defaults to `https`.
105+
106+
```sh
107+
git config [--global] open.[gitdomain].domain [value]
108+
git config [--global] open.[gitdomain].protocol [value]
109+
```
110+
111+
**Example**
112+
- Your git remote is at `ssh://[email protected]:7000/XXX/YYY.git`
113+
- Your hosted gitlab is `http://repo.intranet/subpath/XXX/YYY`
114+
115+
```sh
116+
git config [--global] "open.https://git.internal.biz.domain" "repo.intranet/subpath"
117+
git config [--global] "open.https://git.internal.biz.protocol" "http"
118+
```
119+
120+
121+
## DEBUGGING
122+
123+
You can run `git-open` in `echo` mode, which doesn't open your browser, but just prints the URL to stdout:
124+
125+
```sh
126+
env BROWSER='echo' ./git-open
127+
```
128+
129+
130+
## AUTHORS
131+
132+
Jason McCreary did the initial hard work. Paul Irish based his project on his work.
133+
Since then many contributors have submitted great PRs.
134+
135+
136+
## SEE ALSO
137+
138+
git(1), git-remote(1), git-config(1), [Project page](https://github.com/paulirish/git-open)

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@
3434
"lint:editorconfig": "eclint check git-open* readme* .travis.yml",
3535
"lint:package": "pjv --recommendations --warnings",
3636
"lint:readme": "node ./node_modules/markdownlint/lib/markdownlint.js --config markdownlint.json README.md",
37-
"test": "npm run unit && npm run lint:package && npm run lint:readme && npm run lint:editorconfig",
37+
"lint:man": "node ./node_modules/markdownlint/lib/markdownlint.js --config markdownlint.json git-open.1.md",
38+
"man": "marked-man --version \"git-open $npm_package_version\" --manual \"Git manual\" --section 1 git-open.1.md > git-open.1",
39+
"test": "npm run unit && npm run lint:package && npm run lint:man && npm run lint:readme && npm run lint:editorconfig",
3840
"unit": "bats test/",
3941
"watch": "find . -maxdepth 2 -iname '*bats' -o -iname 'git-open' | entr bats test/"
4042
},
4143
"dependencies": {},
4244
"devDependencies": {
4345
"eclint": "^2.1.0",
4446
"markdownlint": "^0.2.0",
47+
"marked-man": "^0.2.1",
4548
"package-json-validator": "^0.6.1"
4649
}
4750
}

0 commit comments

Comments
 (0)