Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
aa4611dd
H
hub
项目概览
github
/
hub
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
aa4611dd
编写于
2月 28, 2016
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'root-dir'
上级
20f3b0a0
0d3617fd
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
41 addition
and
20 deletion
+41
-20
commands/compare.go
commands/compare.go
+9
-2
commands/create.go
commands/create.go
+2
-1
commands/fetch.go
commands/fetch.go
+4
-1
commands/remote.go
commands/remote.go
+3
-1
features/remote_add.feature
features/remote_add.feature
+8
-0
git/git.go
git/git.go
+9
-0
github/project.go
github/project.go
+6
-4
utils/utils.go
utils/utils.go
+0
-11
未找到文件。
commands/compare.go
浏览文件 @
aa4611dd
...
...
@@ -88,11 +88,18 @@ func compare(command *Command, args *Args) {
usageHelp
()
}
else
{
r
=
parseCompareRange
(
args
.
RemoveParam
(
args
.
ParamsSize
()
-
1
))
project
,
err
=
localRepo
.
CurrentProject
()
if
args
.
IsParamsEmpty
()
{
project
,
err
=
localRepo
.
CurrentProject
()
utils
.
Check
(
err
)
}
else
{
project
=
github
.
NewProject
(
args
.
RemoveParam
(
args
.
ParamsSize
()
-
1
),
""
,
""
)
projectName
:=
""
if
err
==
nil
{
projectName
=
project
.
Name
}
project
=
github
.
NewProject
(
args
.
RemoveParam
(
args
.
ParamsSize
()
-
1
),
projectName
,
""
)
if
project
.
Name
==
""
{
utils
.
Check
(
fmt
.
Errorf
(
"error: missing project name (owner: %q)
\n
"
,
project
.
Owner
))
}
}
}
}
...
...
commands/create.go
浏览文件 @
aa4611dd
...
...
@@ -69,8 +69,9 @@ func create(command *Command, args *Args) {
var
newRepoName
string
if
args
.
IsParamsEmpty
()
{
newRepoName
,
err
=
utils
.
D
irName
()
dirName
,
err
:=
git
.
Workd
irName
()
utils
.
Check
(
err
)
newRepoName
=
github
.
SanitizeProjectName
(
dirName
)
}
else
{
reg
:=
regexp
.
MustCompile
(
"^[^-]"
)
if
!
reg
.
MatchString
(
args
.
FirstParam
())
{
...
...
commands/fetch.go
浏览文件 @
aa4611dd
...
...
@@ -44,13 +44,16 @@ func tranformFetchArgs(args *Args) error {
localRepo
,
err
:=
github
.
LocalRepo
()
utils
.
Check
(
err
)
currentProject
,
err
:=
localRepo
.
CurrentProject
()
utils
.
Check
(
err
)
projects
:=
make
(
map
[
*
github
.
Project
]
bool
)
ownerRegexp
:=
regexp
.
MustCompile
(
OwnerRe
)
for
_
,
name
:=
range
names
{
if
ownerRegexp
.
MatchString
(
name
)
&&
!
isCloneable
(
name
)
{
_
,
err
:=
localRepo
.
RemoteByName
(
name
)
if
err
!=
nil
{
project
:=
github
.
NewProject
(
name
,
""
,
""
)
project
:=
github
.
NewProject
(
name
,
currentProject
.
Name
,
""
)
gh
:=
github
.
NewClient
(
project
.
Host
)
repo
,
err
:=
gh
.
Repository
(
project
)
if
err
!=
nil
{
...
...
commands/remote.go
浏览文件 @
aa4611dd
...
...
@@ -5,6 +5,7 @@ import (
"regexp"
"strings"
"github.com/github/hub/git"
"github.com/github/hub/github"
"github.com/github/hub/utils"
)
...
...
@@ -68,8 +69,9 @@ func transformRemoteArgs(args *Args) {
repoName
=
project
.
Name
host
=
project
.
Host
}
else
{
repoName
,
err
=
utils
.
D
irName
()
dirName
,
err
:=
git
.
Workd
irName
()
utils
.
Check
(
err
)
repoName
=
github
.
SanitizeProjectName
(
dirName
)
}
name
=
repoName
...
...
features/remote_add.feature
浏览文件 @
aa4611dd
...
...
@@ -9,6 +9,14 @@ Feature: hub remote add
Then the url for "origin" should be "git@github.com
:
EvilChelu/dotfiles.git"
And
there should be no output
Scenario
:
Add origin remote for my own repo using -C
Given
there are no remotes
And
I cd to
".."
When
I successfully run `hub -C dotfiles remote add origin`
And
I cd to
"dotfiles"
Then the url for "origin" should be "git@github.com
:
EvilChelu/dotfiles.git"
And
there should be no output
Scenario
:
Unchanged public remote add
When I successfully run `hub remote add origin http
:
//github.com/defunkt/resque.git`
Then the url for "origin" should be "http
:
//github.com/defunkt/resque.git"
...
...
git/git.go
浏览文件 @
aa4611dd
...
...
@@ -64,6 +64,15 @@ func Dir() (string, error) {
return
gitDir
,
nil
}
func
WorkdirName
()
(
string
,
error
)
{
output
,
err
:=
gitOutput
(
"rev-parse"
,
"--show-toplevel"
)
if
err
==
nil
{
return
output
[
0
],
nil
}
else
{
return
""
,
err
}
}
func
HasFile
(
segments
...
string
)
bool
{
// The blessed way to resolve paths within git dir since Git 2.5.0
output
,
err
:=
gitOutput
(
"rev-parse"
,
"-q"
,
"--git-path"
,
filepath
.
Join
(
segments
...
))
...
...
github/project.go
浏览文件 @
aa4611dd
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"net/url"
"os"
"path/filepath"
"strings"
"github.com/github/hub/git"
...
...
@@ -166,10 +167,6 @@ func newProject(owner, name, host, protocol string) *Project {
}
}
if
name
==
""
{
name
,
_
=
utils
.
DirName
()
}
return
&
Project
{
Name
:
name
,
Owner
:
owner
,
...
...
@@ -177,3 +174,8 @@ func newProject(owner, name, host, protocol string) *Project {
Protocol
:
protocol
,
}
}
func
SanitizeProjectName
(
name
string
)
string
{
name
=
filepath
.
Base
(
name
)
return
strings
.
Replace
(
name
,
" "
,
"-"
,
-
1
)
}
utils/utils.go
浏览文件 @
aa4611dd
...
...
@@ -74,17 +74,6 @@ func CommandPath(cmd string) (string, error) {
return
filepath
.
EvalSymlinks
(
path
)
}
func
DirName
()
(
string
,
error
)
{
dir
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
return
""
,
err
}
name
:=
filepath
.
Base
(
dir
)
name
=
strings
.
Replace
(
name
,
" "
,
"-"
,
-
1
)
return
name
,
nil
}
func
IsOption
(
confirm
,
short
,
long
string
)
bool
{
return
strings
.
EqualFold
(
confirm
,
short
)
||
strings
.
EqualFold
(
confirm
,
long
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录