Skip to content

Commit

Permalink
Merge pull request #88 from hotoo/feat/gitcodenet
Browse files Browse the repository at this point in the history
feat: move csdn type to gitcode
  • Loading branch information
hotoo authored Apr 1, 2022
2 parents c9fc92e + ef01f30 commit 926e5b8
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ jobs:
cache: 'npm'
- run: npm ci
- run: make test

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ and
* ~~[GitCafe](https://gitcafe.com/)~~ Merged into coding.net.
* [Coding](https://coding.net/)
* [gitee](https://gitee.com/)
* [CSDN](https://code.csdn.net/)
* [CSDN gitcode.net](https://gitcode.net/)
* [AntCode](https://code.alipay.com/)
* Custom

Expand Down Expand Up @@ -93,7 +93,7 @@ Default support [github.com](https://github.com/),
[coding.net](https://coding.net/),
[gitee.com](https://gitee.com/),
[AntCode](https://code.alipay.com/)
and [CSDN](https://code.csdn.net/).
and CSDN [gitcode.com](https://gitcode.net/).

If you are use [GitHub Enterprise](https://enterprise.github.com/),
[GitLab Community Edition (CE), GitLab Enterprise Edition (EE)](https://gitlab.org/),
Expand Down Expand Up @@ -135,7 +135,7 @@ gitlab.company.net:
```
- `github.company.com`, `gitlab.company.net` is your company's git web server domain name.
- `type` is the type of your company's git web server, support `github`, `gitlab`, `gitbucket`, `coding`, `gitee`, `csdn`, `antcode`.
- `type` is the type of your company's git web server, support `github`, `gitlab`, `gitbucket`, `coding`, `gitee`, `gitcode`, `antcode`.
- `protocol`: protocol of your company's git web server, `http` or `https`.

Else if you are using other custom web system build your owner git server, you need config like:
Expand Down
16 changes: 11 additions & 5 deletions bin/openrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ function openrc(uri, options) {
if (type === 'oschina') {
type = 'gitee';
console.warn('The type of "oschina" is deprecated, please use "gitee" in ~/.gitopenrc file.');
} else if (type === 'csdn') {
type = 'gitcode';
console.warn('The type of "csdn" is deprecated, please use "gitcode" in ~/.gitopenrc file.');
}
gitopenConfig.type = type;
if (type === 'custom') {
Expand All @@ -63,8 +66,7 @@ function openrc(uri, options) {
});
} catch (ex) {
console.error('Read %s error: %s', gitopenrc, ex.message);
process.exit(1);
return {};
return process.exit(1);
}
}

Expand Down Expand Up @@ -101,15 +103,19 @@ function openrc(uri, options) {

// 当 .gitopenrc 中定义为 type=custom,.gitconfig 中定义 type!=custom 时,
// 将 schema 改回 .gitconfig 中定义的 scheme 配置。
if (gitConfig.type && gitConfig.type !== 'custom') {
var type = gitConfig.type;
var type = gitConfig.type;
if (type && type !== 'custom') {
// oschina 更名为 gitee,做兼容,用户可以保持配置为 oschina
if (type === 'oschina') {
type = 'gitee';
console.warn('The type of "oschina" is deprecated, please use "gitee" in git config.');
console.warn('Try to execute command "git config gitopen.type gitee" in terminal.');
} else if (type === 'csdn') {
type = 'gitcode';
console.warn('The type of "csdn" is deprecated, please use "gitcode" in git config.');
console.warn('Try to execute command "git config gitopen.type gitcode" in terminal.');
}
gitConfig.scheme = require('../lib/scheme/' + gitConfig.type);
gitConfig.scheme = require('../lib/scheme/' + type);
}

// 优先使用 gitopenConfig 的配置。
Expand Down
6 changes: 5 additions & 1 deletion lib/gitopenrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ module.exports = {
protocol: "https",
type: "coding"
},
"gitcode.net": {
protocol: "https",
type: "gitcode"
},
"code.csdn.net": {
protocol: "https",
type: "csdn"
type: "gitcode"
},
"code.alipay.com": {
protocol: "https",
Expand Down
32 changes: 0 additions & 32 deletions lib/scheme/csdn.js

This file was deleted.

32 changes: 32 additions & 0 deletions lib/scheme/gitcode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';
module.exports = {
'base': '{protocol}://{hostname}/{username}/{reponame}',
'home': '',
'issues': '/-/issues',
'issues/id': '/-/issues/{issue-id}',
'issues/new': '/-/issues/new',
'issues/new?title': '/-/issues/new?title={title}',
'wiki': '/-/wikis',
'network': '/graph',
'tree': '/-/tree/{hash}{path}',
'blob': '/-/blob/{hash}{path}',
'commit': '/-/commit/{hash}',
'commits': '/-/commits',
'commits-with-branch': '/-/commits/{branch-name}',
'blame': '/-/blame/{branch-name}/{path}',
'branches': '/-/branches',
'milestones': '/-/milestones',
'milestones/new': '/-/milestones/new',
'milestones/id': '/-/milestones/{milestone-id}',
'tags': '/-/tags',
'releases': '',
'releases/new': '',
'releases/new-with-tag': '',
'releases/edit/tag-id': '',
'pulls': '/-/merge_requests',
'pulls/id': '/-/merge_requests/{pull-id}',
'pulls/new': '/-/compare',
'pulls/new-with-compare-branch': '/-/compare/{branch-B}?expand=1',
'pulls/new-with-base-branch': '/-/compare/{branch-A}...{branch-B}',
'snippets/new': '',
};

0 comments on commit 926e5b8

Please sign in to comment.