Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
7f1c0224
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,发现更多精彩内容 >>
提交
7f1c0224
编写于
12月 24, 2014
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #747 from github/backport-cukes-1.12-stable
Backport latest cukes from 1.12-stable branch
上级
a0835d44
f1bc1897
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
106 addition
and
30 deletion
+106
-30
commands/compare.go
commands/compare.go
+21
-1
commands/create.go
commands/create.go
+1
-1
commands/remote.go
commands/remote.go
+12
-6
commands/remote_test.go
commands/remote_test.go
+14
-5
features/compare.feature
features/compare.feature
+12
-0
features/create.feature
features/create.feature
+11
-0
features/pull_request.feature
features/pull_request.feature
+6
-6
features/remote_add.feature
features/remote_add.feature
+14
-11
features/submodule_add.feature
features/submodule_add.feature
+5
-0
features/support/env.rb
features/support/env.rb
+10
-0
未找到文件。
commands/compare.go
浏览文件 @
7f1c0224
...
...
@@ -3,6 +3,8 @@ package commands
import
(
"fmt"
"regexp"
"strings"
"net/url"
"github.com/github/hub/github"
"github.com/github/hub/utils"
...
...
@@ -72,7 +74,7 @@ func compare(command *Command, args *Args) {
}
}
subpage
:=
utils
.
ConcatPaths
(
"compare"
,
r
)
subpage
:=
utils
.
ConcatPaths
(
"compare"
,
r
angeQueryEscape
(
r
)
)
url
:=
project
.
WebURL
(
""
,
""
,
subpage
)
launcher
,
err
:=
utils
.
BrowserLauncher
()
utils
.
Check
(
err
)
...
...
@@ -91,3 +93,21 @@ func parseCompareRange(r string) string {
shaOrTagRangeRegexp
:=
regexp
.
MustCompile
(
shaOrTagRange
)
return
shaOrTagRangeRegexp
.
ReplaceAllString
(
r
,
"$1...$2"
)
}
// characters we want to allow unencoded in compare views
var
compareUnescaper
=
strings
.
NewReplacer
(
"%2F"
,
"/"
,
"%3A"
,
":"
,
"%5E"
,
"^"
,
"%7E"
,
"~"
,
"%2A"
,
"*"
,
"%21"
,
"!"
,
)
func
rangeQueryEscape
(
r
string
)
string
{
if
strings
.
Contains
(
r
,
".."
)
{
return
r
}
else
{
return
compareUnescaper
.
Replace
(
url
.
QueryEscape
(
r
))
}
}
commands/create.go
浏览文件 @
7f1c0224
...
...
@@ -106,7 +106,7 @@ func create(command *Command, args *Args) {
utils
.
Check
(
err
)
remote
,
_
:=
localRepo
.
OriginRemote
()
if
remote
==
nil
{
if
remote
==
nil
||
remote
.
Name
!=
"origin"
{
url
:=
project
.
GitURL
(
""
,
""
,
true
)
args
.
Replace
(
"git"
,
"remote"
,
"add"
,
"-f"
,
"origin"
,
url
)
}
else
{
...
...
commands/remote.go
浏览文件 @
7f1c0224
...
...
@@ -3,6 +3,7 @@ package commands
import
(
"fmt"
"regexp"
"strings"
"github.com/github/hub/github"
"github.com/github/hub/utils"
...
...
@@ -65,16 +66,16 @@ func transformRemoteArgs(args *Args) {
name
=
repoName
}
hostConfig
,
err
:=
github
.
CurrentConfig
()
.
DefaultHost
()
if
err
!=
nil
{
utils
.
Check
(
github
.
FormatError
(
"adding remote"
,
err
))
}
words
:=
args
.
Words
()
isPrivate
:=
parseRemotePrivateFlag
(
args
)
if
len
(
words
)
==
2
&&
words
[
1
]
==
"origin"
{
// Origin special case triggers default user/repo
host
,
err
:=
github
.
CurrentConfig
()
.
DefaultHost
()
if
err
!=
nil
{
utils
.
Check
(
github
.
FormatError
(
"adding remote"
,
err
))
}
owner
=
host
.
User
owner
=
hostConfig
.
User
name
=
repoName
}
else
if
len
(
words
)
==
2
{
// gh remote add jingweno foo/bar
...
...
@@ -85,6 +86,11 @@ func transformRemoteArgs(args *Args) {
args
.
RemoveParam
(
args
.
ParamsSize
()
-
1
)
}
if
strings
.
ToLower
(
owner
)
==
strings
.
ToLower
(
hostConfig
.
User
)
{
owner
=
hostConfig
.
User
isPrivate
=
true
}
project
:=
github
.
NewProject
(
owner
,
name
,
host
)
// for GitHub Enterprise
isPrivate
=
isPrivate
||
project
.
Host
!=
github
.
GitHubHost
...
...
commands/remote_test.go
浏览文件 @
7f1c0224
...
...
@@ -28,16 +28,25 @@ func TestTransformRemoteArgs(t *testing.T) {
assert
.
Equal
(
t
,
3
,
args
.
ParamsSize
())
assert
.
Equal
(
t
,
"add"
,
args
.
FirstParam
())
assert
.
Equal
(
t
,
"jingweno"
,
args
.
GetParam
(
1
))
reg
:=
regexp
.
MustCompile
(
"^git
://github.com/
jingweno/.+
\\
.git$"
)
reg
:=
regexp
.
MustCompile
(
"^git
@github
\\
.com:
jingweno/.+
\\
.git$"
)
assert
.
T
(
t
,
reg
.
MatchString
(
args
.
GetParam
(
2
)))
args
=
NewArgs
([]
string
{
"remote"
,
"add"
,
"
-p"
,
"jingweno
"
})
args
=
NewArgs
([]
string
{
"remote"
,
"add"
,
"
mislav
"
})
transformRemoteArgs
(
args
)
assert
.
Equal
(
t
,
3
,
args
.
ParamsSize
())
assert
.
Equal
(
t
,
"add"
,
args
.
FirstParam
())
assert
.
Equal
(
t
,
"jingweno"
,
args
.
GetParam
(
1
))
reg
=
regexp
.
MustCompile
(
"^git@github.com:jingweno/.+
\\
.git$"
)
assert
.
Equal
(
t
,
"mislav"
,
args
.
GetParam
(
1
))
reg
=
regexp
.
MustCompile
(
"^git://github
\\
.com/mislav/.+
\\
.git$"
)
assert
.
T
(
t
,
reg
.
MatchString
(
args
.
GetParam
(
2
)))
args
=
NewArgs
([]
string
{
"remote"
,
"add"
,
"-p"
,
"mislav"
})
transformRemoteArgs
(
args
)
assert
.
Equal
(
t
,
3
,
args
.
ParamsSize
())
assert
.
Equal
(
t
,
"add"
,
args
.
FirstParam
())
assert
.
Equal
(
t
,
"mislav"
,
args
.
GetParam
(
1
))
reg
=
regexp
.
MustCompile
(
"^git@github
\\
.com:mislav/.+
\\
.git$"
)
assert
.
T
(
t
,
reg
.
MatchString
(
args
.
GetParam
(
2
)))
args
=
NewArgs
([]
string
{
"remote"
,
"add"
,
"origin"
})
...
...
@@ -46,7 +55,7 @@ func TestTransformRemoteArgs(t *testing.T) {
assert
.
Equal
(
t
,
3
,
args
.
ParamsSize
())
assert
.
Equal
(
t
,
"add"
,
args
.
FirstParam
())
assert
.
Equal
(
t
,
"origin"
,
args
.
GetParam
(
1
))
reg
=
regexp
.
MustCompile
(
"^git
://github.com/.+
/.+
\\
.git$"
)
reg
=
regexp
.
MustCompile
(
"^git
@github
\\
.com:jingweno
/.+
\\
.git$"
)
assert
.
T
(
t
,
reg
.
MatchString
(
args
.
GetParam
(
2
)))
args
=
NewArgs
([]
string
{
"remote"
,
"add"
,
"jingweno"
,
"git@github.com:jingweno/gh.git"
})
...
...
features/compare.feature
浏览文件 @
7f1c0224
...
...
@@ -13,6 +13,11 @@ Feature: hub compare
Then
there should be no output
And "open https
:
//github.com/mislav/dotfiles/compare/feature/foo"
should
be
run
Scenario
:
Compare branch with funky characters
When
I successfully run `hub compare 'my#branch!with.special+chars'`
Then
there should be no output
And "open https
:
//github.com/mislav/dotfiles/compare/my%23branch!with.special%2Bchars"
should
be
run
Scenario
:
No
args, no upstream
When
I run `hub compare`
Then
the exit status should be 1
...
...
@@ -38,6 +43,13 @@ Feature: hub compare
Then
there should be no output
And "open https
:
//github.com/mislav/dotfiles/compare/experimental"
should
be
run
Scenario
:
Current branch has funky characters
Given
I am on the
"feature"
branch with upstream
"origin/my#branch!with.special+chars"
And
git
"push.default"
is set to
"upstream"
When
I successfully run `hub compare`
Then
there should be no output
And "open https
:
//github.com/mislav/dotfiles/compare/my%23branch!with.special%2Bchars"
should
be
run
Scenario
:
Compare range
When
I successfully run `hub compare 1.0...fix`
Then
there should be no output
...
...
features/create.feature
浏览文件 @
7f1c0224
...
...
@@ -98,6 +98,17 @@ Feature: hub create
When
I successfully run `hub create`
Then the url for "origin" should be "git
:
//github.com/mislav/dotfiles.git"
Scenario
:
Another remote already exists
Given the GitHub API server
:
"""
post('/user/repos') {
json :full_name => 'mislav/dotfiles'
}
"""
And the "github" remote has url "git
:
//github.com/mislav/dotfiles.git"
When
I successfully run `hub create`
Then the url for "origin" should be "git@github.com
:
mislav/dotfiles.git"
Scenario
:
GitHub repo already exists
Given the GitHub API server
:
"""
...
...
features/pull_request.feature
浏览文件 @
7f1c0224
...
...
@@ -587,11 +587,11 @@ Feature: hub pull-request
Scenario
:
Branch with quotation mark in name
Given
I am on the
"feat'ure"
branch with upstream
"origin/feat'ure"
Given the GitHub API server
:
"""
post('/repos/mislav/coral/pulls') {
assert :head => "mislav:feat'ure"
json :html_url => "the://url"
}
"""
"""
post('/repos/mislav/coral/pulls') {
assert :head => "mislav:feat'ure"
json :html_url => "the://url"
}
"""
When
I successfully run `hub pull-request -m hereyougo`
Then the output should contain exactly "the
:
//url\n"
features/remote_add.feature
浏览文件 @
7f1c0224
Feature
:
hub remote add
Background
:
Given
I am in
"dotfiles"
git repo
Given
I am
"EvilChelu"
on GitHub.com
And
I am in
"dotfiles"
git repo
Scenario
:
Add origin remote for my own repo
Given
I am
"mislav"
on GitHub.com
And
there are no remotes
Given
there are no remotes
When
I successfully run `hub remote add origin`
Then the url for "origin" should be "git
:
//github.com/mislav/dotfiles.git"
And
there should be no output
Scenario
:
Add private origin remote for my own repo
Given
I am
"mislav"
on GitHub.com
And
there are no remotes
When
I successfully run `hub remote add -p origin`
Then the url for "origin" should be "git@github.com
:
mislav/dotfiles.git"
Then the url for "origin" should be "git@github.com
:
EvilChelu/dotfiles.git"
And
there should be no output
Scenario
:
Unchanged public remote add
...
...
@@ -58,6 +51,11 @@ Feature: hub remote add
Then the url for "mislav" should be "git@github.com
:
mislav/dotfiles.git"
And
there should be no output
Scenario
:
Remote for my own repo is automatically private
When
I successfully run `hub remote add evilchelu`
Then the url for "evilchelu" should be "git@github.com
:
EvilChelu/dotfiles.git"
And
there should be no output
Scenario
:
Add remote with arguments
When
I successfully run `hub remote add -f mislav`
Then "git remote add -f mislav git
:
//github.com/mislav/dotfiles.git"
should
be
run
...
...
@@ -104,3 +102,8 @@ Feature: hub remote add
When
I successfully run `hub remote add -p mm mislav/dotfilez.js`
Then the url for "mm" should be "git@github.com
:
mislav/dotfilez.js.git"
And
there should be no output
Scenario
:
Add named private remote for my own repo including repo name
When
I successfully run `hub remote add ec evilchelu/dotfilez.js`
Then the url for "ec" should be "git@github.com
:
EvilChelu/dotfilez.js.git"
And
there should be no output
features/submodule_add.feature
浏览文件 @
7f1c0224
...
...
@@ -16,6 +16,11 @@ Feature: hub submodule add
When
I successfully run `hub submodule add -p mojombo/grit vendor/grit`
Then the "vendor/grit" submodule url should be "git@github.com
:
mojombo/grit.git"
Scenario
:
A
submodule for my own repo is public nevertheless
Given
I am
"EvilChelu"
on GitHub.com
When
I successfully run `hub submodule add grit vendor/grit`
Then the "vendor/grit" submodule url should be "git
:
//github.com/EvilChelu/grit.git"
Scenario
:
Add submodule with arguments
When
I successfully run `hub submodule add -b foo --name grit mojombo/grit vendor/grit`
Then "git submodule add -b foo --name grit git
:
//github.com/mojombo/grit.git
vendor/grit"
should
be
run
...
...
features/support/env.rb
浏览文件 @
7f1c0224
...
...
@@ -3,6 +3,16 @@ require 'fileutils'
require
'forwardable'
require
'tmpdir'
# Ruby 2.2.0 compat
Cucumber
::
Ast
::
Step
.
class_eval
do
undef_method
:text_length
def
text_length
(
name
=
name
())
self
.
class
::
INDENT
+
self
.
class
::
INDENT
+
keyword
.
unpack
(
'U*'
).
length
+
name
.
unpack
(
'U*'
).
length
end
end
system_git
=
`which git 2>/dev/null`
.
chomp
lib_dir
=
File
.
expand_path
(
'../../../lib'
,
__FILE__
)
bin_dir
=
File
.
expand_path
(
'../fakebin'
,
__FILE__
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录