Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
db292bcf
H
hub
项目概览
github
/
hub
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
db292bcf
编写于
6月 24, 2013
作者:
J
Jingwen Owen Ou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up git.go
上级
391503fa
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
15 addition
and
39 deletion
+15
-39
commands/checkout.go
commands/checkout.go
+1
-1
commands/commands.go
commands/commands.go
+1
-1
commands/remote.go
commands/remote.go
+1
-1
git/git.go
git/git.go
+10
-34
git/remote.go
git/remote.go
+1
-1
github/github.go
github/github.go
+1
-1
未找到文件。
commands/checkout.go
浏览文件 @
db292bcf
...
...
@@ -29,7 +29,7 @@ func checkout(command *Command, args []string) {
utils
.
Fatal
(
err
)
}
err
=
git
.
ExecCheckout
(
args
)
err
=
git
.
SysExec
(
"checkout"
,
args
...
)
utils
.
Check
(
err
)
}
...
...
commands/commands.go
浏览文件 @
db292bcf
...
...
@@ -20,7 +20,7 @@ type Command struct {
func
(
c
*
Command
)
PrintUsage
()
{
if
c
.
GitExtension
{
err
:=
git
.
ExecHelp
(
c
.
Name
()
)
err
:=
git
.
SysExec
(
c
.
Name
(),
"--help"
)
utils
.
Check
(
err
)
}
else
{
if
c
.
Runnable
()
{
...
...
commands/remote.go
浏览文件 @
db292bcf
...
...
@@ -29,7 +29,7 @@ func remote(command *Command, args []string) {
args
=
transformRemoteArgs
(
args
)
}
err
:=
git
.
ExecRemote
(
args
...
)
err
:=
git
.
SysExec
(
"remote"
,
args
...
)
utils
.
Check
(
err
)
}
...
...
git/git.go
浏览文件 @
db292bcf
...
...
@@ -10,7 +10,7 @@ import (
)
func
Version
()
(
string
,
error
)
{
output
,
err
:=
execGitCmd
(
[]
string
{
"version"
}
)
output
,
err
:=
execGitCmd
(
"version"
)
if
err
!=
nil
{
return
""
,
errors
.
New
(
"Can't load git version"
)
}
...
...
@@ -19,7 +19,7 @@ func Version() (string, error) {
}
func
Dir
()
(
string
,
error
)
{
output
,
err
:=
execGitCmd
(
[]
string
{
"rev-parse"
,
"-q"
,
"--git-dir"
}
)
output
,
err
:=
execGitCmd
(
"rev-parse"
,
"-q"
,
"--git-dir"
)
if
err
!=
nil
{
return
""
,
errors
.
New
(
"Not a git repository (or any of the parent directories): .git"
)
}
...
...
@@ -43,7 +43,7 @@ func PullReqMsgFile() (string, error) {
}
func
Editor
()
(
string
,
error
)
{
output
,
err
:=
execGitCmd
(
[]
string
{
"var"
,
"GIT_EDITOR"
}
)
output
,
err
:=
execGitCmd
(
"var"
,
"GIT_EDITOR"
)
if
err
!=
nil
{
return
""
,
errors
.
New
(
"Can't load git var: GIT_EDITOR"
)
}
...
...
@@ -74,7 +74,7 @@ func EditorPath() (string, error) {
}
func
Head
()
(
string
,
error
)
{
output
,
err
:=
execGitCmd
(
[]
string
{
"symbolic-ref"
,
"-q"
,
"--short"
,
"HEAD"
}
)
output
,
err
:=
execGitCmd
(
"symbolic-ref"
,
"-q"
,
"--short"
,
"HEAD"
)
if
err
!=
nil
{
return
"master"
,
errors
.
New
(
"Can't load git HEAD"
)
}
...
...
@@ -83,7 +83,7 @@ func Head() (string, error) {
}
func
Ref
(
ref
string
)
(
string
,
error
)
{
output
,
err
:=
execGitCmd
(
[]
string
{
"rev-parse"
,
"-q"
,
ref
}
)
output
,
err
:=
execGitCmd
(
"rev-parse"
,
"-q"
,
ref
)
if
err
!=
nil
{
return
""
,
errors
.
New
(
"Unknown revision or path not in the working tree: "
+
ref
)
}
...
...
@@ -91,32 +91,6 @@ func Ref(ref string) (string, error) {
return
output
[
0
],
nil
}
func
ExecRemote
(
args
...
string
)
error
{
cmdArgs
:=
make
([]
string
,
0
)
cmdArgs
=
append
(
cmdArgs
,
"remote"
)
cmdArgs
=
append
(
cmdArgs
,
args
...
)
return
SysExec
(
cmdArgs
...
)
}
func
AddRemote
(
name
,
url
string
)
error
{
_
,
err
:=
execGitCmd
([]
string
{
"remote"
,
"add"
,
"-f"
,
name
,
url
})
return
err
}
func
ExecCheckout
(
args
[]
string
)
error
{
cmdArgs
:=
make
([]
string
,
0
)
cmdArgs
=
append
(
cmdArgs
,
"checkout"
)
cmdArgs
=
append
(
cmdArgs
,
args
...
)
return
SysExec
(
cmdArgs
...
)
}
func
ExecHelp
(
command
string
)
error
{
return
SysExec
(
command
,
"--help"
)
}
func
Log
(
sha1
,
sha2
string
)
(
string
,
error
)
{
execCmd
:=
cmd
.
New
(
"git"
)
execCmd
.
WithArg
(
"log"
)
.
WithArg
(
"--no-color"
)
...
...
@@ -133,8 +107,9 @@ func Log(sha1, sha2 string) (string, error) {
return
outputs
,
nil
}
func
SysExec
(
args
...
string
)
error
{
func
SysExec
(
command
string
,
args
...
string
)
error
{
cmd
:=
cmd
.
New
(
"git"
)
cmd
.
WithArg
(
command
)
for
_
,
a
:=
range
args
{
cmd
.
WithArg
(
a
)
}
...
...
@@ -142,8 +117,9 @@ func SysExec(args ...string) error {
return
cmd
.
SysExec
()
}
func
Spawn
(
args
...
string
)
error
{
func
Spawn
(
command
string
,
args
...
string
)
error
{
cmd
:=
cmd
.
New
(
"git"
)
cmd
.
WithArg
(
command
)
for
_
,
a
:=
range
args
{
cmd
.
WithArg
(
a
)
}
...
...
@@ -156,7 +132,7 @@ func Spawn(args ...string) error {
return
nil
}
func
execGitCmd
(
input
[]
string
)
(
outputs
[]
string
,
err
error
)
{
func
execGitCmd
(
input
...
string
)
(
outputs
[]
string
,
err
error
)
{
cmd
:=
cmd
.
New
(
"git"
)
for
_
,
i
:=
range
input
{
cmd
.
WithArg
(
i
)
...
...
git/remote.go
浏览文件 @
db292bcf
...
...
@@ -12,7 +12,7 @@ type GitRemote struct {
func
Remotes
()
([]
GitRemote
,
error
)
{
r
:=
regexp
.
MustCompile
(
"(.+)
\t
(.+github.com.+)
\\
(push
\\
)"
)
output
,
err
:=
execGitCmd
(
[]
string
{
"remote"
,
"-v"
}
)
output
,
err
:=
execGitCmd
(
"remote"
,
"-v"
)
if
err
!=
nil
{
return
nil
,
errors
.
New
(
"Can't load git remote"
)
}
...
...
github/github.go
浏览文件 @
db292bcf
...
...
@@ -77,7 +77,7 @@ func (gh *GitHub) ForkRepository(name, owner string, noRemote bool) (newRemote s
if
!
noRemote
{
newRemote
=
config
.
User
err
=
git
.
AddRemote
(
config
.
User
,
repo
.
SshURL
)
err
=
git
.
Spawn
(
"remote"
,
"add"
,
"-f"
,
config
.
User
,
repo
.
SshURL
)
}
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录