Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
827e1d67
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,发现更多精彩内容 >>
提交
827e1d67
编写于
7月 25, 2014
作者:
J
Jingwen Owen Ou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix apply to recognize enterprise URLs
上级
0c9c9083
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
31 deletion
+65
-31
commands/apply.go
commands/apply.go
+39
-31
features/support/fakebin/curl
features/support/fakebin/curl
+26
-0
未找到文件。
commands/apply.go
浏览文件 @
827e1d67
...
...
@@ -5,6 +5,8 @@ import (
"os"
"path/filepath"
"regexp"
"github.com/github/hub/github"
)
var
cmdApply
=
&
Command
{
...
...
@@ -44,44 +46,50 @@ func apply(command *Command, args *Args) {
}
func
transformApplyArgs
(
args
*
Args
)
{
urlRegexp
:=
regexp
.
MustCompile
(
"^https?://(gist
\\
.)?github
\\
.com/"
)
for
_
,
url
:=
range
args
.
Params
{
if
urlRegexp
.
MatchString
(
url
)
{
idx
:=
args
.
IndexOfParam
(
url
)
gist
:=
urlRegexp
.
FindStringSubmatch
(
url
)[
1
]
==
"gist."
fragmentRegexp
:=
regexp
.
MustCompile
(
"#.+"
)
url
=
fragmentRegexp
.
ReplaceAllString
(
url
,
""
)
pullRegexp
:=
regexp
.
MustCompile
(
"(/pull/
\\
d+)/
\\
w*$"
)
if
!
gist
{
if
pullRegexp
.
MatchString
(
url
)
{
pull
:=
pullRegexp
.
FindStringSubmatch
(
url
)[
1
]
url
=
pullRegexp
.
ReplaceAllString
(
url
,
pull
)
}
urlRegexp
:=
regexp
.
MustCompile
(
"^https?://(gist
\\
.)github
\\
.com/"
)
for
_
,
arg
:=
range
args
.
Params
{
var
(
url
string
gist
bool
)
projectURL
,
err
:=
github
.
ParseURL
(
arg
)
if
err
==
nil
{
pullRegexp
:=
regexp
.
MustCompile
(
"/(pull|commit)/([0-9a-f]+)"
)
match
:=
pullRegexp
.
FindStringSubmatch
(
projectURL
.
Path
)
if
match
!=
nil
{
url
=
projectURL
.
Project
.
WebURL
(
""
,
""
,
match
[
1
]
+
"/"
+
match
[
2
])
}
var
ext
string
}
else
{
gist
=
urlRegexp
.
MatchString
(
arg
)
if
gist
{
ext
=
".txt"
}
else
{
ext
=
".patch"
}
if
filepath
.
Ext
(
url
)
!=
ext
{
url
+=
ext
url
=
arg
}
}
var
prefix
string
if
gist
{
prefix
=
"gist-"
}
if
url
==
""
{
continue
}
patchFile
:=
filepath
.
Join
(
os
.
TempDir
(),
prefix
+
filepath
.
Base
(
url
))
var
ext
string
if
gist
{
ext
=
".txt"
}
else
{
ext
=
".patch"
}
args
.
Before
(
"curl"
,
"-#LA"
,
fmt
.
Sprintf
(
"gh %s"
,
Version
),
url
,
"-o"
,
patchFile
)
args
.
Params
[
idx
]
=
patchFile
idx
:=
args
.
IndexOfParam
(
arg
)
if
filepath
.
Ext
(
url
)
!=
ext
{
url
+=
ext
}
break
var
prefix
string
if
gist
{
prefix
=
"gist-"
}
patchFile
:=
filepath
.
Join
(
os
.
TempDir
(),
prefix
+
filepath
.
Base
(
url
))
args
.
Before
(
"curl"
,
"-#LA"
,
fmt
.
Sprintf
(
"gh %s"
,
Version
),
url
,
"-o"
,
patchFile
)
args
.
Params
[
idx
]
=
patchFile
}
}
features/support/fakebin/curl
0 → 100755
浏览文件 @
827e1d67
#!/bin/bash
set -e
url="$3"
file="$5"
if [ "${url%.patch}" = "$url" ]; then
echo "invalid pull request URL: $url" >&2
exit 1
fi
cat > "$file" <<OUT
From 7eb75a26ee8e402aad79fcf36a4c1461e3ec2592 Mon Sep 17 00:00:00 2001
From: Mislav <mislav.marohnic@gmail.com>
Date: Tue, 24 Jun 2014 11:07:05 -0700
Subject: [PATCH] Create a README
---
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ce01362
--- /dev/null
+++ b/README.md
+hello
--
1.9.3
OUT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录