Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fsmiamoto
Copy link
Contributor

As discussed in #1288, this PR allows for the use of the :branch placeholder on the api command.

The placeholder is substituted with the current git branch name.

Closes #1288

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Two tiny points

}

var branch string
if strings.Contains(value, ":branch") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a subtle bug here: the placeholderRE matches only :branch\b (notice the word boundary), but strings.Contains matches ":branch" even when it's not on a word boundary.

So I would move the branch lookup logic to the below case ":branch" block

IO: f.IOStreams,
HttpClient: f.HttpClient,
BaseRepo: f.BaseRepo,
CurrentBranch: git.CurrentBranch,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of git.CurrentBranch, you can pass f.Branch, since this is already what a cmdutil.Factory provides and allows the current branch to be mocked easier in tests

@fsmiamoto
Copy link
Contributor Author

@mislav
Thanks for the review!
I've made the suggested changes 👍

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨✨

@mislav mislav merged commit 55a13a3 into cli:trunk Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add :branch placeholder to api command

3 participants