Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
76b49068
H
hub
项目概览
github
/
hub
大约 1 年 前同步成功
通知
3
Star
22523
Fork
2406
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
76b49068
编写于
7月 05, 2013
作者:
J
Jingwen Owen Ou
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'add_no_op'
上级
f9ecb8b4
fe8904c1
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
234 addition
and
102 deletion
+234
-102
cmd/cmd.go
cmd/cmd.go
+8
-4
commands/args.go
commands/args.go
+10
-2
commands/browse.go
commands/browse.go
+29
-5
commands/ci_status.go
commands/ci_status.go
+37
-15
commands/clone.go
commands/clone.go
+4
-4
commands/clone_test.go
commands/clone_test.go
+6
-0
commands/compare.go
commands/compare.go
+16
-4
commands/fork.go
commands/fork.go
+21
-6
commands/pull_request.go
commands/pull_request.go
+57
-24
commands/remote.go
commands/remote.go
+1
-1
commands/runner.go
commands/runner.go
+39
-9
commands/utils.go
commands/utils.go
+0
-13
github/github.go
github/github.go
+6
-15
未找到文件。
cmd/cmd.go
浏览文件 @
76b49068
...
...
@@ -18,13 +18,17 @@ func (cmd Cmd) String() string {
}
func
(
cmd
*
Cmd
)
WithArg
(
arg
string
)
*
Cmd
{
if
arg
!=
""
{
cmd
.
Args
=
append
(
cmd
.
Args
,
arg
)
}
return
cmd
}
func
(
cmd
*
Cmd
)
WithArgs
(
args
...
string
)
*
Cmd
{
cmd
.
Args
=
append
(
cmd
.
Args
,
args
...
)
for
_
,
arg
:=
range
args
{
cmd
.
WithArg
(
arg
)
}
return
cmd
}
...
...
@@ -64,9 +68,9 @@ func (cmd *Cmd) SysExec() error {
}
func
New
(
name
string
)
*
Cmd
{
return
&
Cmd
{
name
,
make
([]
string
,
0
)}
return
&
Cmd
{
Name
:
name
,
Args
:
make
([]
string
,
0
)}
}
func
NewWithArray
(
cmd
[]
string
)
*
Cmd
{
return
&
Cmd
{
cmd
[
0
],
cmd
[
1
:
]}
return
&
Cmd
{
Name
:
cmd
[
0
],
Args
:
cmd
[
1
:
]}
}
commands/args.go
浏览文件 @
76b49068
...
...
@@ -6,10 +6,12 @@ import (
)
type
Args
struct
{
Executable
string
Command
string
Params
[]
string
beforeChain
[]
*
cmd
.
Cmd
afterChain
[]
*
cmd
.
Cmd
Noop
bool
}
func
(
a
*
Args
)
Before
(
command
...
string
)
{
...
...
@@ -20,6 +22,12 @@ func (a *Args) After(command ...string) {
a
.
afterChain
=
append
(
a
.
afterChain
,
cmd
.
NewWithArray
(
command
))
}
func
(
a
*
Args
)
Replace
(
executable
,
command
string
,
params
...
string
)
{
a
.
Executable
=
executable
a
.
Command
=
command
a
.
Params
=
params
}
func
(
a
*
Args
)
Commands
()
[]
*
cmd
.
Cmd
{
result
:=
a
.
beforeChain
result
=
append
(
result
,
a
.
ToCmd
())
...
...
@@ -29,7 +37,7 @@ func (a *Args) Commands() []*cmd.Cmd {
}
func
(
a
*
Args
)
ToCmd
()
*
cmd
.
Cmd
{
return
cmd
.
New
(
"git"
)
.
WithArg
(
a
.
Command
)
.
WithArgs
(
a
.
Params
...
)
return
cmd
.
New
(
a
.
Executable
)
.
WithArg
(
a
.
Command
)
.
WithArgs
(
a
.
Params
...
)
}
func
(
a
*
Args
)
GetParam
(
i
int
)
string
{
...
...
@@ -99,7 +107,7 @@ func NewArgs(args []string) *Args {
params
=
args
[
1
:
]
}
return
&
Args
{
command
,
params
,
make
([]
*
cmd
.
Cmd
,
0
),
make
([]
*
cmd
.
Cmd
,
0
)}
return
&
Args
{
Executable
:
"git"
,
Command
:
command
,
Params
:
params
,
beforeChain
:
make
([]
*
cmd
.
Cmd
,
0
),
afterChain
:
make
([]
*
cmd
.
Cmd
,
0
)}
}
func
removeItem
(
slice
[]
string
,
index
int
)
(
newSlice
[]
string
,
item
string
)
{
...
...
commands/browse.go
浏览文件 @
76b49068
...
...
@@ -3,7 +3,6 @@ package commands
import
(
"github.com/jingweno/gh/github"
"github.com/jingweno/gh/utils"
"os"
)
var
cmdBrowse
=
&
Command
{
...
...
@@ -25,10 +24,32 @@ func init() {
cmdBrowse
.
Flag
.
StringVar
(
&
flagBrowseRepo
,
"r"
,
""
,
"REPOSITORY"
)
}
/*
$ gh browse
> open https://github.com/YOUR_USER/CURRENT_REPO
$ gh browse commit/SHA
> open https://github.com/YOUR_USER/CURRENT_REPO/commit/SHA
$ gh browse issues
> open https://github.com/YOUR_USER/CURRENT_REPO/issues
$ gh browse -u jingweno -r gh
> open https://github.com/jingweno/gh
$ gh browse -u jingweno -r gh commit/SHA
> open https://github.com/jingweno/gh/commit/SHA
$ gh browse -r resque
> open https://github.com/YOUR_USER/resque
$ gh browse -r resque network
> open https://github.com/YOUR_USER/resque/network
*/
func
browse
(
command
*
Command
,
args
*
Args
)
{
subpage
:=
"tree"
if
!
args
.
IsParamsEmpty
()
{
subpage
=
args
.
FirstParam
(
)
subpage
=
args
.
RemoveParam
(
0
)
}
project
:=
github
.
CurrentProject
()
...
...
@@ -38,8 +59,11 @@ func browse(command *Command, args *Args) {
}
url
:=
project
.
WebURL
(
flagBrowseRepo
,
flagBrowseUser
,
subpage
)
err
:=
browserCommand
(
url
)
launcher
,
err
:=
utils
.
BrowserLauncher
()
if
err
!=
nil
{
utils
.
Check
(
err
)
}
os
.
Exit
(
0
)
args
.
Replace
(
launcher
[
0
],
""
,
launcher
[
1
:
]
...
)
args
.
AppendParams
(
url
)
}
commands/ci_status.go
浏览文件 @
76b49068
...
...
@@ -19,23 +19,53 @@ success (0), error (1), failure (1), pending (2), no status (3)
`
,
}
/*
$ gh ci-status
> (prints CI state of HEAD and exits with appropriate code)
> One of: success (0), error (1), failure (1), pending (2), no status (3)
$ gh ci-status BRANCH
> (prints CI state of BRANCH and exits with appropriate code)
> One of: success (0), error (1), failure (1), pending (2), no status (3)
$ gh ci-status SHA
> (prints CI state of SHA and exits with appropriate code)
> One of: success (0), error (1), failure (1), pending (2), no status (3)
*/
func
ciStatus
(
cmd
*
Command
,
args
*
Args
)
{
ref
:=
"HEAD"
if
!
args
.
IsParamsEmpty
()
{
ref
=
args
.
FirstParam
(
)
ref
=
args
.
RemoveParam
(
0
)
}
ref
,
err
:=
git
.
Ref
(
ref
)
utils
.
Check
(
err
)
args
.
Replace
(
""
,
""
)
if
args
.
Noop
{
fmt
.
Printf
(
"Would request CI status for %s"
,
ref
)
}
else
{
state
,
targetURL
,
desc
,
exitCode
,
err
:=
fetchCiStatus
(
ref
)
utils
.
Check
(
err
)
fmt
.
Println
(
state
)
if
targetURL
!=
""
{
fmt
.
Println
(
targetURL
)
}
if
desc
!=
""
{
fmt
.
Println
(
desc
)
}
os
.
Exit
(
exitCode
)
}
}
func
fetchCiStatus
(
ref
string
)
(
state
,
targetURL
,
desc
string
,
exitCode
int
,
err
error
)
{
gh
:=
github
.
New
()
status
,
err
:=
gh
.
CiStatus
(
ref
)
utils
.
Check
(
err
)
if
err
!=
nil
{
return
}
var
state
string
var
targetURL
string
var
desc
string
var
exitCode
int
if
status
==
nil
{
state
=
"no status"
}
else
{
...
...
@@ -55,13 +85,5 @@ func ciStatus(cmd *Command, args *Args) {
exitCode
=
3
}
fmt
.
Println
(
state
)
if
targetURL
!=
""
{
fmt
.
Println
(
targetURL
)
}
if
desc
!=
""
{
fmt
.
Println
(
desc
)
}
os
.
Exit
(
exitCode
)
return
}
commands/clone.go
浏览文件 @
76b49068
...
...
@@ -20,13 +20,13 @@ For repositories under your GitHub login, -p is implicit.
/**
$ gh clone jingweno/gh
> git clone git://github.com/jingweno/gh
> git clone git://github.com/jingweno/gh
.git
$ gh clone -p jingweno/gh
> git clone git@github.com:jingweno/gh.git
$ gh clone jekyll_and_hy
p
e
> git clone git://github.com/YOUR_LOGIN/jekyll_and_hy
pe.
$ gh clone jekyll_and_hy
d
e
> git clone git://github.com/YOUR_LOGIN/jekyll_and_hy
de.git
$ gh clone -p jekyll_and_hyde
> git clone git@github.com:YOUR_LOGIN/jekyll_and_hyde.git
...
...
@@ -49,10 +49,10 @@ func transformCloneArgs(args *Args) {
if
nameWithOwnerRegexp
.
MatchString
(
a
)
&&
!
isDir
(
a
)
{
name
,
owner
:=
parseCloneNameAndOwner
(
a
)
config
:=
github
.
CurrentConfig
()
isSSH
=
isSSH
||
owner
==
config
.
User
if
owner
==
""
{
owner
=
config
.
User
}
isSSH
=
isSSH
||
owner
==
config
.
User
project
:=
github
.
Project
{
Name
:
name
,
Owner
:
owner
}
url
:=
project
.
GitURL
(
name
,
owner
,
isSSH
)
...
...
commands/clone_test.go
浏览文件 @
76b49068
...
...
@@ -38,6 +38,12 @@ func TestTransformCloneArgs(t *testing.T) {
assert
.
Equal
(
t
,
1
,
args
.
ParamsSize
())
assert
.
Equal
(
t
,
"git@github.com:acl-services/devise-acl.git"
,
args
.
FirstParam
())
args
=
NewArgs
([]
string
{
"clone"
,
"jekyll_and_hyde"
})
transformCloneArgs
(
args
)
assert
.
Equal
(
t
,
1
,
args
.
ParamsSize
())
assert
.
Equal
(
t
,
"git://github.com/jingweno/jekyll_and_hyde.git"
,
args
.
FirstParam
())
args
=
NewArgs
([]
string
{
"clone"
,
"-p"
,
"jekyll_and_hyde"
})
transformCloneArgs
(
args
)
...
...
commands/compare.go
浏览文件 @
76b49068
...
...
@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/jingweno/gh/github"
"github.com/jingweno/gh/utils"
"os"
"regexp"
)
...
...
@@ -26,6 +25,16 @@ func init() {
cmdCompare
.
Flag
.
StringVar
(
&
flagCompareUser
,
"u"
,
""
,
"USER"
)
}
/*
$ gh compare refactor
> open https://github.com/CURRENT_REPO/compare/refactor
$ gh compare 1.0..1.1
> open https://github.com/CURRENT_REPO/compare/1.0...1.1
$ gh compare -u other-user patch
> open https://github.com/other-user/REPO/compare/patch
*/
func
compare
(
command
*
Command
,
args
*
Args
)
{
project
:=
github
.
CurrentProject
()
...
...
@@ -40,10 +49,13 @@ func compare(command *Command, args *Args) {
r
=
transformToTripleDots
(
r
)
subpage
:=
utils
.
ConcatPaths
(
"compare"
,
r
)
url
:=
project
.
WebURL
(
""
,
flagCompareUser
,
subpage
)
err
:=
browserCommand
(
url
)
launcher
,
err
:=
utils
.
BrowserLauncher
()
if
err
!=
nil
{
utils
.
Check
(
err
)
}
os
.
Exit
(
0
)
args
.
Replace
(
launcher
[
0
],
""
,
launcher
[
1
:
]
...
)
args
.
AppendParams
(
url
)
}
func
transformToTripleDots
(
r
string
)
string
{
...
...
commands/fork.go
浏览文件 @
76b49068
...
...
@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/jingweno/gh/github"
"github.com/jingweno/gh/utils"
"os"
)
var
cmdFork
=
&
Command
{
...
...
@@ -22,16 +21,32 @@ func init() {
cmdFork
.
Flag
.
BoolVar
(
&
flagForkNoRemote
,
"no-remote"
,
false
,
""
)
}
/*
$ gh fork
[ repo forked on GitHub ]
> git remote add -f YOUR_USER git@github.com:YOUR_USER/CURRENT_REPO.git
$ gh fork --no-remote
[ repo forked on GitHub ]
*/
func
fork
(
cmd
*
Command
,
args
*
Args
)
{
gh
:=
github
.
New
()
project
:=
gh
.
Project
newRemote
,
err
:=
gh
.
ForkRepository
(
project
.
Name
,
project
.
Owner
,
flagForkNoRemote
)
var
forkURL
string
if
args
.
Noop
{
args
.
Before
(
fmt
.
Sprintf
(
"Would request a fork to %s:%s"
,
project
.
Owner
,
project
.
Name
),
""
)
forkURL
=
"FORK_URL"
}
else
{
repo
,
err
:=
gh
.
ForkRepository
(
project
.
Name
,
project
.
Owner
,
flagForkNoRemote
)
utils
.
Check
(
err
)
if
!
flagForkNoRemote
&&
newRemote
!=
""
{
fmt
.
Printf
(
"New remote: %s
\n
"
,
newRemote
)
forkURL
=
repo
.
SshURL
}
os
.
Exit
(
0
)
if
!
flagForkNoRemote
{
newRemote
:=
gh
.
Config
.
User
args
.
Replace
(
"git"
,
"remote"
,
"add"
,
"-f"
,
newRemote
,
forkURL
)
args
.
After
(
"echo"
,
fmt
.
Sprintf
(
"New remote: %s"
,
newRemote
))
}
}
commands/pull_request.go
浏览文件 @
76b49068
...
...
@@ -8,7 +8,6 @@ import (
"github.com/jingweno/gh/github"
"github.com/jingweno/gh/utils"
"io/ioutil"
"log"
"os"
"regexp"
"strings"
...
...
@@ -43,52 +42,86 @@ func init() {
cmdPullRequest
.
Flag
.
StringVar
(
&
flagPullRequestIssue
,
"i"
,
""
,
"ISSUE"
)
}
/*
# while on a topic branch called "feature":
$ gh pull-request
[ opens text editor to edit title & body for the request ]
[ opened pull request on GitHub for "YOUR_USER:feature" ]
# explicit pull base & head:
$ gh pull-request -b jingweno:master -h jingweno:feature
$ gh pull-request -i 123
[ attached pull request to issue #123 ]
*/
func
pullRequest
(
cmd
*
Command
,
args
*
Args
)
{
var
title
,
body
string
var
(
title
,
body
string
err
error
)
if
args
.
ParamsSize
()
==
1
{
title
=
args
.
FirstParam
(
)
title
=
args
.
RemoveParam
(
0
)
}
gh
:=
github
.
New
()
repo
:=
gh
.
Project
.
LocalRepoWith
(
flagPullRequestBase
,
flagPullRequestHead
)
if
title
==
""
&&
flagPullRequestIssue
==
""
{
messageFile
,
err
:=
git
.
PullReqMsgFile
(
)
utils
.
Check
(
err
)
title
,
body
,
err
=
writePullRequestTitleAndBody
(
repo
)
}
err
=
writePullRequestChanges
(
repo
,
messageFile
)
utils
.
Check
(
err
)
if
title
==
""
&&
flagPullRequestIssue
==
""
{
utils
.
Check
(
fmt
.
Errorf
(
"Aborting due to empty pull request title"
))
}
editorPath
,
err
:=
git
.
EditorPath
()
var
pullRequestURL
string
if
args
.
Noop
{
args
.
Before
(
fmt
.
Sprintf
(
"Would request a pull request to %s from %s"
,
repo
.
FullBase
(),
repo
.
FullHead
()),
""
)
pullRequestURL
=
"PULL_REQUEST_URL"
}
else
{
if
title
!=
""
{
pullRequestURL
,
err
=
gh
.
CreatePullRequest
(
repo
.
Base
,
repo
.
Head
,
title
,
body
)
}
utils
.
Check
(
err
)
err
=
editTitleAndBody
(
editorPath
,
messageFile
)
if
flagPullRequestIssue
!=
""
{
pullRequestURL
,
err
=
gh
.
CreatePullRequestForIssue
(
repo
.
Base
,
repo
.
Head
,
flagPullRequestIssue
)
}
utils
.
Check
(
err
)
title
,
body
,
err
=
readTitleAndBody
(
messageFile
)
utils
.
Check
(
err
)
}
err
=
os
.
Remove
(
messageFile
)
utils
.
Check
(
err
)
args
.
Replace
(
"echo"
,
""
,
pullRequestURL
)
}
func
writePullRequestTitleAndBody
(
repo
*
github
.
Repo
)
(
title
,
body
string
,
err
error
)
{
messageFile
,
err
:=
git
.
PullReqMsgFile
()
if
err
!=
nil
{
return
}
if
title
==
""
&&
flagPullRequestIssue
==
""
{
log
.
Fatal
(
"Aborting due to empty pull request title"
)
err
=
writePullRequestChanges
(
repo
,
messageFile
)
if
err
!=
nil
{
return
}
var
pullRequestURL
string
var
err
error
if
title
!=
""
{
pullRequestURL
,
err
=
gh
.
CreatePullRequest
(
repo
.
Base
,
repo
.
Head
,
title
,
body
)
editorPath
,
err
:=
git
.
EditorPath
()
if
err
!=
nil
{
return
}
if
flagPullRequestIssue
!=
""
{
pullRequestURL
,
err
=
gh
.
CreatePullRequestForIssue
(
repo
.
Base
,
repo
.
Head
,
flagPullRequestIssue
)
err
=
editTitleAndBody
(
editorPath
,
messageFile
)
if
err
!=
nil
{
return
}
utils
.
Check
(
err
)
title
,
body
,
err
=
readTitleAndBody
(
messageFile
)
if
err
!=
nil
{
return
}
fmt
.
Println
(
pullRequestURL
)
err
=
os
.
Remove
(
messageFile
)
os
.
Exit
(
0
)
return
}
func
writePullRequestChanges
(
repo
*
github
.
Repo
,
messageFile
string
)
error
{
...
...
commands/remote.go
浏览文件 @
76b49068
...
...
@@ -33,7 +33,7 @@ then uses your GitHub login.
> git remote add origin git://github.com/YOUR_LOGIN/THIS_REPO.git
*/
func
remote
(
command
*
Command
,
args
*
Args
)
{
if
args
.
ParamsSize
()
>=
2
&&
(
args
.
Command
==
"add"
||
args
.
Command
==
"set-url"
)
{
if
args
.
ParamsSize
()
>=
2
&&
(
args
.
FirstParam
()
==
"add"
||
args
.
FirstParam
()
==
"set-url"
)
{
transformRemoteArgs
(
args
)
}
}
...
...
commands/runner.go
浏览文件 @
76b49068
...
...
@@ -2,6 +2,7 @@ package commands
import
(
"fmt"
"github.com/jingweno/gh/cmd"
"github.com/jingweno/gh/git"
)
...
...
@@ -16,6 +17,7 @@ func (r *Runner) Execute() error {
}
expandAlias
(
args
)
slurpGlobalFlags
(
args
)
for
_
,
cmd
:=
range
All
()
{
if
cmd
.
Name
()
==
args
.
Command
&&
cmd
.
Runnable
()
{
...
...
@@ -33,6 +35,38 @@ func (r *Runner) Execute() error {
cmd
.
Run
(
cmd
,
args
)
cmds
:=
args
.
Commands
()
if
args
.
Noop
{
printCommands
(
cmds
)
}
else
{
err
:=
executeCommands
(
cmds
)
if
err
!=
nil
{
return
err
}
}
return
nil
}
}
return
git
.
SysExec
(
args
.
Command
,
args
.
Params
...
)
}
func
slurpGlobalFlags
(
args
*
Args
)
{
for
i
,
p
:=
range
args
.
Params
{
if
p
==
"--no-op"
{
args
.
Noop
=
true
args
.
RemoveParam
(
i
)
}
}
}
func
printCommands
(
cmds
[]
*
cmd
.
Cmd
)
{
for
_
,
c
:=
range
cmds
{
fmt
.
Println
(
c
)
}
}
func
executeCommands
(
cmds
[]
*
cmd
.
Cmd
)
error
{
length
:=
len
(
cmds
)
for
i
,
c
:=
range
cmds
{
var
err
error
...
...
@@ -48,10 +82,6 @@ func (r *Runner) Execute() error {
}
return
nil
}
}
return
git
.
SysExec
(
args
.
Command
,
args
.
Params
...
)
}
func
expandAlias
(
args
*
Args
)
{
...
...
commands/utils.go
浏览文件 @
76b49068
...
...
@@ -2,25 +2,12 @@ package commands
import
(
"fmt"
"github.com/jingweno/gh/cmd"
"github.com/jingweno/gh/github"
"github.com/jingweno/gh/utils"
"github.com/jingweno/octokat"
"os"
"regexp"
)
func
browserCommand
(
url
string
)
error
{
launcher
,
err
:=
utils
.
BrowserLauncher
()
if
err
!=
nil
{
return
err
}
launcher
=
append
(
launcher
,
url
)
c
:=
cmd
.
NewWithArray
(
launcher
)
return
c
.
Exec
()
}
func
isDir
(
file
string
)
bool
{
f
,
err
:=
os
.
Open
(
file
)
if
err
!=
nil
{
...
...
github/github.go
浏览文件 @
76b49068
...
...
@@ -3,7 +3,6 @@ package github
import
(
"errors"
"fmt"
"github.com/jingweno/gh/git"
"github.com/jingweno/octokat"
)
...
...
@@ -14,7 +13,7 @@ const (
type
GitHub
struct
{
Project
*
Project
c
onfig
*
Config
C
onfig
*
Config
}
func
(
gh
*
GitHub
)
PullRequest
(
id
string
)
(
*
octokat
.
PullRequest
,
error
)
{
...
...
@@ -59,10 +58,10 @@ func (gh *GitHub) CiStatus(sha string) (*octokat.Status, error) {
return
&
statuses
[
0
],
nil
}
func
(
gh
*
GitHub
)
ForkRepository
(
name
,
owner
string
,
noRemote
bool
)
(
newRemote
string
,
err
error
)
{
func
(
gh
*
GitHub
)
ForkRepository
(
name
,
owner
string
,
noRemote
bool
)
(
repo
*
octokat
.
Repository
,
err
error
)
{
client
:=
gh
.
client
()
config
:=
gh
.
c
onfig
repo
,
err
:
=
client
.
Repository
(
octokat
.
Repo
{
name
,
config
.
User
})
config
:=
gh
.
C
onfig
repo
,
err
=
client
.
Repository
(
octokat
.
Repo
{
name
,
config
.
User
})
if
repo
!=
nil
&&
err
==
nil
{
msg
:=
fmt
.
Sprintf
(
"Error creating fork: %s exists on %s"
,
repo
.
FullName
,
GitHubHost
)
err
=
errors
.
New
(
msg
)
...
...
@@ -70,14 +69,6 @@ func (gh *GitHub) ForkRepository(name, owner string, noRemote bool) (newRemote s
}
repo
,
err
=
client
.
Fork
(
octokat
.
Repo
{
name
,
owner
},
nil
)
if
err
!=
nil
{
return
}
if
!
noRemote
{
newRemote
=
config
.
User
err
=
git
.
Spawn
(
"remote"
,
"add"
,
"-f"
,
config
.
User
,
repo
.
SshURL
)
}
return
}
...
...
@@ -85,7 +76,7 @@ func (gh *GitHub) ForkRepository(name, owner string, noRemote bool) (newRemote s
func
(
gh
*
GitHub
)
ExpandRemoteUrl
(
owner
,
name
string
,
isSSH
bool
)
(
url
string
)
{
project
:=
gh
.
Project
if
owner
==
"origin"
{
config
:=
gh
.
c
onfig
config
:=
gh
.
C
onfig
owner
=
config
.
FetchUser
()
}
...
...
@@ -130,7 +121,7 @@ func findOrCreateToken(user, password string) (string, error) {
}
func
(
gh
*
GitHub
)
client
()
*
octokat
.
Client
{
config
:=
gh
.
c
onfig
config
:=
gh
.
C
onfig
config
.
FetchCredentials
()
return
octokat
.
NewClient
()
.
WithToken
(
config
.
Token
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录