Skip to content

Commit

Permalink
feat: add PR number in workspace info (#1212)
Browse files Browse the repository at this point in the history
Signed-off-by: tarunrajput <[email protected]>
  • Loading branch information
tarunrajput authored Oct 8, 2024
1 parent d5d15cf commit 5f1c130
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/views/workspace/info/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ func getSingleProjectOutput(project *apiclient.Project, isCreationView bool) str
output += getInfoLineGitStatus("Branch", &project.State.GitStatus) + "\n"
}

output += getInfoLinePrNumber(project.Repository.PrNumber, project.Repository, project.State)

if !isCreationView {
output += getInfoLine("Target", project.Target) + "\n"
}
Expand All @@ -120,6 +122,8 @@ func getProjectsOutputs(projects []apiclient.Project, isCreationView bool) strin
if project.State != nil {
output += getInfoLineGitStatus("Branch", &project.State.GitStatus)
}
output += getInfoLinePrNumber(project.Repository.PrNumber, project.Repository, project.State)

if !isCreationView {
output += getInfoLine("Target", project.Target)
}
Expand Down Expand Up @@ -195,3 +199,10 @@ func getInfoLineGitStatus(key string, status *apiclient.GitStatus) string {

return output
}

func getInfoLinePrNumber(PrNumber *int32, repo apiclient.GitRepository, state *apiclient.ProjectState) string {
if PrNumber != nil && (state == nil || state.GitStatus.CurrentBranch == repo.Branch) {
return getInfoLine("PR Number", fmt.Sprintf("#%d", *PrNumber)) + "\n"
}
return ""
}

0 comments on commit 5f1c130

Please sign in to comment.