Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
cce67b40
H
hub
项目概览
github
/
hub
9 个月 前同步成功
通知
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 搜索 >>
提交
cce67b40
编写于
12月 24, 2014
作者:
M
Mislav Marohnić
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #741 from github/funky-branch-compare
Encode special characters in branch names for `compare` command
上级
0b076c30
f06b6191
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
5 deletion
+20
-5
features/compare.feature
features/compare.feature
+12
-0
lib/hub/commands.rb
lib/hub/commands.rb
+8
-5
未找到文件。
features/compare.feature
浏览文件 @
cce67b40
...
...
@@ -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
...
...
lib/hub/commands.rb
浏览文件 @
cce67b40
...
...
@@ -704,9 +704,9 @@ module Hub
path
=
case
subpage
when
'commits'
"/commits/
#{
branch_in_url
(
branch
)
}
"
"/commits/
#{
branch_in_url
(
branch
.
short_name
)
}
"
when
'tree'
,
NilClass
"/tree/
#{
branch_in_url
(
branch
)
}
"
if
branch
and
!
branch
.
master?
"/tree/
#{
branch_in_url
(
branch
.
short_name
)
}
"
if
branch
and
!
branch
.
master?
else
"/
#{
subpage
}
"
end
...
...
@@ -742,7 +742,8 @@ module Hub
end
end
path
=
'/compare/%s'
%
range
escaped_range
=
range
.
include?
(
'..'
)
?
range
:
branch_in_url
(
range
)
path
=
'/compare/%s'
%
escaped_range
project
.
web_url
(
path
,
api_client
.
config
.
method
(
:protocol
))
end
end
...
...
@@ -842,8 +843,10 @@ module Hub
# from the command line.
#
def
branch_in_url
(
branch
)
CGI
.
escape
(
branch
.
short_name
).
gsub
(
"%2F"
,
"/"
)
def
branch_in_url
(
branch_name
)
branch_name
.
to_str
.
gsub
(
/[^\w!.*'():^~\/-]/
)
do
|
char
|
'%'
+
char
.
unpack
(
'H2'
*
char
.
bytesize
).
join
(
'%'
).
upcase
end
end
def
api_client
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录