未验证 提交 55307933 编写于 作者: M Mislav Marohnić 提交者: GitHub

Merge pull request #2097 from github/labels-no-color

Fix issue/PR labels output in no-color mode
......@@ -313,16 +313,13 @@ func formatIssuePlaceholders(issue github.Issue, colorize bool) map[string]strin
var labelStrings []string
var rawLabels []string
for _, label := range issue.Labels {
if !colorize {
labelStrings = append(labelStrings, fmt.Sprintf(" %s ", label.Name))
continue
}
color, err := utils.NewColor(label.Color)
if err != nil {
if colorize {
color, err := utils.NewColor(label.Color)
utils.Check(err)
labelStrings = append(labelStrings, colorizeLabel(label, color))
} else {
labelStrings = append(labelStrings, fmt.Sprintf(" %s ", label.Name))
}
labelStrings = append(labelStrings, colorizeLabel(label, color))
rawLabels = append(rawLabels, label.Name)
}
......
......@@ -247,6 +247,38 @@ Feature: hub issue
13,mislav\n
"""
Scenario: Custom format with no-color labels
Given the GitHub API server:
"""
get('/repos/github/hub/issues') {
json [
{ :number => 102,
:title => "First issue",
:state => "open",
:user => { :login => "morganwahl" },
:labels => [
{ :name => 'Has Migration',
:color => 'cfcfcf' },
{ :name => 'Maintenance Window',
:color => '888888' },
]
},
{ :number => 201,
:title => "No labels",
:state => "open",
:user => { :login => "octocat" },
:labels => []
},
]
}
"""
When I successfully run `hub issue -f "%I: %L%n" --color=never`
Then the output should contain exactly:
"""
102: Has Migration, Maintenance Window
201: \n
"""
Scenario: List all assignees
Given the GitHub API server:
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册