Skip to content

Commit

Permalink
Merge pull request #664 from Scalingo/fix/612/review-app-URL
Browse files Browse the repository at this point in the history
Fix(review-app-url) add app url in the tablewriter
  • Loading branch information
EtienneM authored Jun 3, 2021
2 parents da7032d + 8be6c92 commit 0c6480c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* bump github.com/fatih/color from 1.11.0 to 1.12.0: add support for `NO_COLOR` environment variable.
* bump github.com/briandowns/spinner from 1.12.0 to 1.13.0
* fix(backup-download) Now download the last successful backup [#663](https://github.com/Scalingo/cli/pull/663)
* fix(review-app-url) add app url in the tablewriter [#664](https://github.com/Scalingo/cli/pull/664)

### 1.20.2

Expand Down
15 changes: 10 additions & 5 deletions review_apps/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,34 @@ import (
"github.com/Scalingo/cli/utils"
)

func Show(app string) error {
func Show(appID string) error {
c, err := config.ScalingoClient()
if err != nil {
return errgo.Notef(err, "fail to get Scalingo client")
}

reviewApps, err := c.SCMRepoLinkReviewApps(app)
reviewApps, err := c.SCMRepoLinkReviewApps(appID)
if err != nil {
return errgo.Notef(err, "fail to get review apps for this app")
}
if len(reviewApps) == 0 {
io.Statusf("No review app for '%s' or specified app is not a parent app.\n", app)
io.Statusf("No review app for '%s' or specified app is not a parent app.\n", appID)
return nil
}

t := tablewriter.NewWriter(os.Stdout)
t.SetHeader([]string{"App", "PR", "PR Branch", "Created At", "Status"})
t.SetHeader([]string{"App", "PR", "PR Branch", "Created At", "Status", "URL"})
for _, ra := range reviewApps {
date := ra.CreatedAt.Local().Format(utils.TimeFormat)

app, err := c.AppsShow(ra.AppID)
if err != nil {
return errgo.Notef(err, "fail to get app from review app")
}

t.Append([]string{
ra.AppName, fmt.Sprintf("%d", ra.PullRequest.Number), ra.PullRequest.BranchName,
date, fmt.Sprintf("%v", ra.LastDeployment.Status),
date, fmt.Sprintf("%v", ra.LastDeployment.Status), app.Url,
})
}
t.Render()
Expand Down

0 comments on commit 0c6480c

Please sign in to comment.