Skip to content

Commit 51caa23

Browse files
authored
Merge pull request #110 from ffes/add-man-page
Add man page
2 parents 8caa9ad + ed3a6d0 commit 51caa23

File tree

5 files changed

+144
-38
lines changed

5 files changed

+144
-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
@@ -104,43 +104,7 @@ git-open can automatically guess the corresponding repository page for remotes
104104
105105
## Configuration
106106
107-
### Configuring the web destination (aka GitLab support)
108-
109-
To configure GitLab support (or other unique hosting situations) you need to set some options.
110-
111-
| option name | description |
112-
| ------------------------- | ---------------- |
113-
| open.[gitdomain].domain | The (web) domain to open based on the provided git repo domain |
114-
| open.[gitdomain].protocol | The (web) protocol to open based on the provided git repo domain. (Defaults to `https`) |
115-
116-
117-
```sh
118-
git config [--global] open.[gitdomain].domain [value]
119-
git config [--global] open.[gitdomain].protocol [value]
120-
```
121-
122-
**Example**
123-
* Your git remote is at `ssh://[email protected]:7000/XXX/YYY.git`
124-
* Your hosted gitlab is `http://repo.intranet/subpath/XXX/YYY`
125-
126-
```sh
127-
git config [--global] "open.https://git.internal.biz.domain" "repo.intranet/subpath"
128-
git config [--global] "open.https://git.internal.biz.protocol" "http"
129-
```
130-
131-
### Configuring which remote to open
132-
133-
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.
134-
135-
In some instances, you may want to override this behavior. When you fork a project
136-
and add a remote named `upstream` you often want that upstream to be opened
137-
rather than your fork. To accomplish this, you can set the `open.default.remote` within your project:
138-
139-
```sh
140-
git config open.default.remote upstream
141-
```
142-
143-
This is equivalent to always typing `git open upstream`.
107+
See the [man page](git-open.1.md) for more information on how to configure `git-open`.
144108
145109
## Alternative projects
146110

git-open.1.md

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

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,22 @@
3030
"git-open": "git-open",
3131
"git-home": "git-open"
3232
},
33+
"man": "./git-open.1",
3334
"scripts": {
3435
"lint:editorconfig": "eclint check git-open* readme* .travis.yml",
3536
"lint:package": "pjv --recommendations --warnings",
3637
"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",
38+
"lint:man": "node ./node_modules/markdownlint/lib/markdownlint.js --config markdownlint.json git-open.1.md",
39+
"man": "marked-man --version \"git-open $npm_package_version\" --manual \"Git manual\" --section 1 git-open.1.md > git-open.1",
40+
"test": "npm run unit && npm run lint:package && npm run lint:man && npm run lint:readme && npm run lint:editorconfig",
3841
"unit": "bats test/",
3942
"watch": "find . -maxdepth 2 -iname '*bats' -o -iname 'git-open' | entr bats test/"
4043
},
4144
"dependencies": {},
4245
"devDependencies": {
4346
"eclint": "^2.1.0",
4447
"markdownlint": "^0.2.0",
48+
"marked-man": "^0.2.1",
4549
"package-json-validator": "^0.6.1"
4650
}
4751
}

0 commit comments

Comments
 (0)