Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
github
hub
提交
51ee76e6
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 搜索 >>
未验证
提交
51ee76e6
编写于
9月 06, 2019
作者:
M
Mislav Marohnić
提交者:
GitHub
9月 06, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2256 from github/github-repository-env
Make hub easier to use from GitHub Actions
上级
2fa955ae
4a107fd2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
1 deletion
+49
-1
features/authentication.feature
features/authentication.feature
+25
-0
github/config.go
github/config.go
+7
-0
share/man/man1/hub.1.md
share/man/man1/hub.1.md
+17
-1
未找到文件。
features/authentication.feature
浏览文件 @
51ee76e6
...
...
@@ -289,6 +289,31 @@ Feature: OAuth authentication
And
the output should not contain
"github.com username"
And
the file
"../home/.config/hub"
should not exist
Scenario
:
Credentials from GITHUB_TOKEN and GITHUB_REPOSITORY
Given I am in "git
:
//github.com/monalisa/playground.git"
git
repo
Given the GitHub API server
:
"""
get('/user') {
status 403
json :message => "Resource not accessible by integration",
:documentation_url => "https://developer.github.com/v3/users/#get-the-authenticated-user"
}
get('/repos/monalisa/playground/releases') {
halt 401 unless request.env["HTTP_AUTHORIZATION"] == "token OTOKEN"
json [
{ tag_name: 'v1.2.0',
}
]
}
"""
Given
$GITHUB_TOKEN is
"OTOKEN"
Given
$GITHUB_REPOSITORY is
"mona-lisa/play-ground"
Given
$GITHUB_USER is
""
When
I successfully run `hub release show v1.2.0`
Then
the output should not contain
"github.com password"
And
the output should not contain
"github.com username"
And
the file
"../home/.config/hub"
should not exist
Scenario
:
Credentials from GITHUB_TOKEN override those from config file
Given
I am
"mislav"
on github.com with OAuth token
"OTOKEN"
Given the GitHub API server
:
...
...
github/config.go
浏览文件 @
51ee76e6
...
...
@@ -88,6 +88,13 @@ func (c *Config) PromptForHost(host string) (h *Host, err error) {
}
userFromEnv
:=
os
.
Getenv
(
"GITHUB_USER"
)
repoFromEnv
:=
os
.
Getenv
(
"GITHUB_REPOSITORY"
)
if
userFromEnv
==
""
&&
repoFromEnv
!=
""
{
repoParts
:=
strings
.
SplitN
(
repoFromEnv
,
"/"
,
2
)
if
len
(
repoParts
)
>
0
{
userFromEnv
=
repoParts
[
0
]
}
}
if
tokenFromEnv
&&
userFromEnv
!=
""
{
h
.
User
=
userFromEnv
}
else
{
...
...
share/man/man1/hub.1.md
浏览文件 @
51ee76e6
...
...
@@ -173,11 +173,27 @@ this can be affected with the `GITHUB_HOST` environment variable:
searched for in
`XDG_CONFIG_DIRS`
per XDG Base Directory Specification.
`HUB_PROTOCOL`
: Use one of "https|ssh|git" as preferred protocol for git clone/push.
: One of "https", "ssh", or "git" as preferred protocol for git clone/push.
`GITHUB_HOST`
: The GitHub hostname to default to instead of "github.com".
`GITHUB_TOKEN`
: OAuth token to use for GitHub API requests.
`GITHUB_USER`
: The GitHub username of the actor of GitHub API operations.
`GITHUB_PASSWORD`
: The GitHub password used to exchange user credentials for an OAuth token
that gets stored in hub configuration. If not set, it may be interactively
prompted for on first run.
`GITHUB_REPOSITORY`
: A value in "OWNER/REPO" format that specifies the repository that API
operations should be performed against. Currently only used to infer the
default value of
`GITHUB_USER`
for API requests.
## Bugs
<https://github.com/github/hub/issues>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录