Skip to content

Commit

Permalink
Merge pull request #60 from hotoo/feat/blame
Browse files Browse the repository at this point in the history
feat: gitopen blame
  • Loading branch information
hotoo committed May 7, 2017
2 parents 3bd4784 + 1aa8512 commit a10eee4
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -112,7 +112,7 @@ gitlab.company.net:
- `type` is the type of you git web server, support `github`, `gitlab`, `gitbucket`, `coding`, `oschina`, `csdn`.
- `protocol`: protocol of you git web server, `http` or `https`.

Else if you use other custom web system build you owner git server, you need config like:
Else if you are using other custom web system build you owner git server, you need config like:

```yaml
git.example.com:
Expand Down Expand Up @@ -190,6 +190,10 @@ alias:

support `@`, `/`, `#`, `:`, `-` or without sparator.

### $ gitopen blame path/to/file

Open file blame information page.

### $ gitopen commits

Open git repository commits list page.
Expand Down
8 changes: 8 additions & 0 deletions bin/open-commander.js
Expand Up @@ -66,6 +66,7 @@ module.exports = function(argv, option, callback) {
console.log(' {directory} Open directory by given branch, default is current working branch.');
console.log(' wiki Open wiki page');
console.log(' commits Open commits list page, alias `ci`');
console.log(' blame <filePath> Open file blame information page.');
console.log(' branches Open branches list page, alias `brs` and `branchs`');
console.log(' tags Open tags list page');
console.log(' milestones Open milestones list page');
Expand Down Expand Up @@ -247,6 +248,13 @@ module.exports = function(argv, option, callback) {
options.category = 'commits-with-branch';
}
break;
case 'blame':
options.category = 'blame';
options.branch = commander.branch || option.cwb;
options.args = {
path: commander.args[1],
};
break;
case 'brs':
case 'branchs':
case 'branches':
Expand Down
4 changes: 4 additions & 0 deletions lib/index.js
Expand Up @@ -150,6 +150,10 @@ module.exports = function(uri, options) {
path = scheme['commits-with-branch']
.replace('{branch-name}', gitremote.encodeBranchName(options.branch));
break;
case 'blame':
path = scheme.blame.replace('{branch-name}', options.branch)
.replace('{path}', options.args.path);
break;
case 'brs':
case 'branchs':
case 'branches':
Expand Down
1 change: 1 addition & 0 deletions lib/scheme/bitbucket.js
Expand Up @@ -13,6 +13,7 @@ module.exports = {
'commit': '/commits/{hash}',
'commits': '/commits',
'commits-with-branch': '/commits/{branch-name}',
'blame': '/annotate/blame/{branch-name}/{path}?at={branch-name}&fileviewer=file-view-default',
'branches': '/branches/',
'milestones': '/admin/issues/milestones',
'milestones/new': '/admin/issues/milestones',
Expand Down
1 change: 1 addition & 0 deletions lib/scheme/coding.js
Expand Up @@ -13,6 +13,7 @@ module.exports = {
'commit': '/commit/{hash}',
'commits': '/git/commits',
'commits-with-branch': '/git/commits/{branch-name}',
'blame': '/blame/{branch-name}/{path}',
'branches': '/git/branches',
'milestones': '/milestones',
'milestones/new': '/milestones/new',
Expand Down
1 change: 1 addition & 0 deletions lib/scheme/csdn.js
Expand Up @@ -13,6 +13,7 @@ module.exports = {
'commit': '/commit/{hash}',
'commits': '/commits',
'commits-with-branch': '/commits/{branch-name}',
'blame': '/blame/{branch-name}/{path}',
'branches': '/repository/branches',
'milestones': '',
'milestones/new': '',
Expand Down
1 change: 1 addition & 0 deletions lib/scheme/github.js
Expand Up @@ -13,6 +13,7 @@ module.exports = {
'commit': '/commit/{hash}',
'commits': '/commits',
'commits-with-branch': '/commits/{branch-name}',
'blame': '/blame/{branch-name}/{path}',
'branches': '/branches',
'milestones': '/milestones',
'milestones/new': '/milestones/new',
Expand Down
1 change: 1 addition & 0 deletions lib/scheme/gitlab.js
Expand Up @@ -13,6 +13,7 @@ module.exports = {
'commit': '/commit/{hash}',
'commits': '/commits',
'commits-with-branch': '/commits/{branch-name}',
'blame': '/blame/{branch-name}/{path}',
'branches': '/branches',
'milestones': '/milestones',
'milestones/new': '/milestones/new',
Expand Down
1 change: 1 addition & 0 deletions lib/scheme/oschina.js
Expand Up @@ -13,6 +13,7 @@ module.exports = {
'commit': '/commit/{hash}',
'commits': '/commits/master',
'commits-with-branch': '/commits/{branch-name}',
'blame': '/blame/{branch-name}/{path}',
'branches': '/branches',
'milestones': '/milestones',
'milestones/new': '/milestones/new',
Expand Down
2 changes: 2 additions & 0 deletions test/gitopen.test.js
Expand Up @@ -483,6 +483,8 @@ describe('$ gitopen', function() {
['ci', '/hotoo/gitopen/commits'],
['commit', '/hotoo/gitopen/commits'],
['commits', '/hotoo/gitopen/commits'],
['blame path/to/file', '/hotoo/gitopen/blame/' + cwb + '/path/to/file'],
['blame -b branch-name path/to/file', '/hotoo/gitopen/blame/branch-name/path/to/file'],
['ed8d9e3', '/hotoo/gitopen/commit/ed8d9e3'],
['brs', '/hotoo/gitopen/branches'],
['branches', '/hotoo/gitopen/branches'],
Expand Down

0 comments on commit a10eee4

Please sign in to comment.