Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark current position in stack #171

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions github/githubclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,17 @@ func (c *client) CreatePullRequest(ctx context.Context,
return pr
}

func formatStackMarkdown(stack []*github.PullRequest) string {
func formatStackMarkdown(commit git.Commit, stack []*github.PullRequest) string {
var buf bytes.Buffer
for i := len(stack) - 1; i >= 0; i-- {
buf.WriteString(fmt.Sprintf("- #%d\n", stack[i].Number))
isCurrent := stack[i].Commit == commit
var suffix string
if isCurrent {
suffix = " ⮜"
} else {
suffix = ""
}
buf.WriteString(fmt.Sprintf("- #%d%s\n", stack[i].Number, suffix))
}

return buf.String()
Expand All @@ -297,7 +304,7 @@ func formatBody(commit git.Commit, stack []*github.PullRequest) string {
if len(stack) <= 1 {
return commit.Body
}
return fmt.Sprintf("**Stack**:\n%s\n\n%s", formatStackMarkdown(stack), commit.Body)
return fmt.Sprintf("**Stack**:\n%s\n\n%s", formatStackMarkdown(commit, stack), commit.Body)
}

func (c *client) UpdatePullRequest(ctx context.Context,
Expand Down