Skip to content

Commit

Permalink
mr: Use bang to denote MR IDs
Browse files Browse the repository at this point in the history
In Gitlab's UI, issues appear as #123 and merge requests as !123.
Follow that convention when outputting MR IDs.
  • Loading branch information
fmuellner authored and prarit committed Dec 14, 2020
1 parent fb024b8 commit c1bc35a
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cmd/mr_approve.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var mrApproveCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
fmt.Printf("Merge Request #%d approved\n", id)
fmt.Printf("Merge Request !%d approved\n", id)
},
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/mr_approve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Test_mrApprove(t *testing.T) {
origOutput := string(b)
origOutput = stripansi.Strip(origOutput)

require.Contains(t, origOutput, `Merge Request #18 approved`)
require.Contains(t, origOutput, `Merge Request !18 approved`)
}

func Test_mrUnapprove(t *testing.T) {
Expand All @@ -60,5 +60,5 @@ func Test_mrUnapprove(t *testing.T) {
origOutput := string(b)
origOutput = stripansi.Strip(origOutput)

require.Contains(t, origOutput, `Merge Request #18 unapproved`)
require.Contains(t, origOutput, `Merge Request !18 unapproved`)
}
2 changes: 1 addition & 1 deletion cmd/mr_checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var checkoutCmd = &cobra.Command{
log.Fatal(err)
}
if len(mrs) < 1 {
fmt.Printf("MR #%d not found\n", mrID)
fmt.Printf("MR !%d not found\n", mrID)
return
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/mr_close.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var mrCloseCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
fmt.Printf("Merge Request #%d closed\n", id)
fmt.Printf("Merge Request !%d closed\n", id)
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/mr_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var listCmd = &cobra.Command{
config.UserConfigError()
}
for _, mr := range mrs {
fmt.Printf("#%d %s\n", mr.IID, mr.Title)
fmt.Printf("!%d %s\n", mr.IID, mr.Title)
}
},
}
Expand Down
28 changes: 14 additions & 14 deletions cmd/mr_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func Test_mrListAssignedTo(t *testing.T) {

mrs := strings.Split(string(b), "\n")
t.Log(mrs)
require.Contains(t, mrs, "#1 Test MR for lab list")
require.NotContains(t, mrs, "#3")
require.Contains(t, mrs, "!1 Test MR for lab list")
require.NotContains(t, mrs, "!3")
require.NotContains(t, mrs, "filtering with labels and lists")
}

Expand All @@ -40,7 +40,7 @@ func Test_mrList(t *testing.T) {

mrs := strings.Split(string(b), "\n")
t.Log(mrs)
require.Contains(t, mrs, "#1 Test MR for lab list")
require.Contains(t, mrs, "!1 Test MR for lab list")
}

func Test_mrListFlagLabel(t *testing.T) {
Expand All @@ -56,7 +56,7 @@ func Test_mrListFlagLabel(t *testing.T) {

mrs := strings.Split(string(b), "\n")
t.Log(mrs)
require.Contains(t, mrs, "#3 for testings filtering with labels and lists")
require.Contains(t, mrs, "!3 for testings filtering with labels and lists")
}

func Test_mrListStateMerged(t *testing.T) {
Expand All @@ -72,7 +72,7 @@ func Test_mrListStateMerged(t *testing.T) {

mrs := strings.Split(string(b), "\n")
t.Log(mrs)
require.Contains(t, mrs, "#4 merged merge request")
require.Contains(t, mrs, "!4 merged merge request")
}

func Test_mrListStateClosed(t *testing.T) {
Expand All @@ -88,7 +88,7 @@ func Test_mrListStateClosed(t *testing.T) {

mrs := strings.Split(string(b), "\n")
t.Log(mrs)
require.Contains(t, mrs, "#5 closed mr")
require.Contains(t, mrs, "!5 closed mr")

}

Expand All @@ -105,7 +105,7 @@ func Test_mrListFivePerPage(t *testing.T) {

mrs := strings.Split(string(b), "\n")
t.Log(mrs)
require.Contains(t, mrs, "#1 Test MR for lab list")
require.Contains(t, mrs, "!1 Test MR for lab list")
}

func Test_mrFilterByTargetBranch(t *testing.T) {
Expand All @@ -123,7 +123,7 @@ func Test_mrFilterByTargetBranch(t *testing.T) {
assert.Empty(t, mrs, "Expected to find no MRs for non-existent branch")
}

var latestUpdatedTestMR = "#19 MR for closing and reopening"
var latestUpdatedTestMR = "!19 MR for closing and reopening"

func Test_mrListByTargetBranch(t *testing.T) {
t.Parallel()
Expand All @@ -141,7 +141,7 @@ func Test_mrListByTargetBranch(t *testing.T) {
}

// updated,asc
// #1
// !1
func Test_mrListUpdatedAscending(t *testing.T) {
t.Parallel()
repo := copyTestRepo(t)
Expand All @@ -155,11 +155,11 @@ func Test_mrListUpdatedAscending(t *testing.T) {

mrs := strings.Split(string(b), "\n")
t.Log(mrs)
require.Contains(t, mrs, "#3 for testings filtering with labels and lists")
require.Contains(t, mrs, "!3 for testings filtering with labels and lists")
}

// updatead,desc
// #18
// !18
func Test_mrListUpdatedDescending(t *testing.T) {
t.Parallel()
repo := copyTestRepo(t)
Expand All @@ -177,7 +177,7 @@ func Test_mrListUpdatedDescending(t *testing.T) {
}

// created,asc
// #1
// !1
func Test_mrListCreatedAscending(t *testing.T) {
t.Parallel()
repo := copyTestRepo(t)
Expand All @@ -191,11 +191,11 @@ func Test_mrListCreatedAscending(t *testing.T) {

mrs := strings.Split(string(b), "\n")
t.Log(mrs)
require.Contains(t, mrs, "#1 Test MR for lab list")
require.Contains(t, mrs, "!1 Test MR for lab list")
}

// created,desc
// #18
// !18
func Test_mrListCreatedDescending(t *testing.T) {
t.Parallel()
repo := copyTestRepo(t)
Expand Down
2 changes: 1 addition & 1 deletion cmd/mr_reopen.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var mrReopenCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
fmt.Printf("Merge Request #%d reopened\n", id)
fmt.Printf("Merge Request !%d reopened\n", id)
},
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/mr_reopen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func Test_mrCloseReopen(t *testing.T) {
{
desc: "close-open",
opt: "close",
expected: "Merge Request #19 closed",
expected: "Merge Request !19 closed",
},
{
desc: "close-closed",
Expand All @@ -31,7 +31,7 @@ func Test_mrCloseReopen(t *testing.T) {
{
desc: "reopen-closed",
opt: "reopen",
expected: "Merge Request #19 reopened",
expected: "Merge Request !19 reopened",
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/mr_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func printMR(mr *gitlab.MergeRequest, project string, renderMarkdown bool) {
}

fmt.Printf(`
#%d %s
!%d %s
===================================
%s
-----------------------------------
Expand Down
2 changes: 1 addition & 1 deletion cmd/mr_show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Test_mrShow(t *testing.T) {

out := string(b)
require.Contains(t, out, `
#1 Test MR for lab list
!1 Test MR for lab list
===================================
This MR is to remain open for testing the `+"`lab mr list`"+` functionality
-----------------------------------
Expand Down
8 changes: 4 additions & 4 deletions cmd/mr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Test_mrCmd(t *testing.T) {
require.Contains(t, out, "Branches: mrtest->master\n")
require.Contains(t, out, "Status: Open\n")
require.Contains(t, out, "Assignee: lab-testing\n")
require.Contains(t, out, fmt.Sprintf("#%s mr title", mrID))
require.Contains(t, out, fmt.Sprintf("!%s mr title", mrID))
require.Contains(t, out, "===================================")
require.Contains(t, outStripped, "mr description")
require.Contains(t, out, fmt.Sprintf("WebURL: https://gitlab.com/lab-testing/test/-/merge_requests/%s", mrID))
Expand All @@ -88,7 +88,7 @@ func Test_mrCmd(t *testing.T) {
t.Log(string(b))
t.Fatal(err)
}
require.Contains(t, string(b), fmt.Sprintf("Merge Request #%s closed", mrID))
require.Contains(t, string(b), fmt.Sprintf("Merge Request !%s closed", mrID))
})
}

Expand Down Expand Up @@ -204,7 +204,7 @@ func Test_mrCmd_MR_description_and_options(t *testing.T) {
t.Log(string(b))
t.Fatal(err)
}
require.Contains(t, string(b), fmt.Sprintf("Merge Request #%s closed", mrID))
require.Contains(t, string(b), fmt.Sprintf("Merge Request !%s closed", mrID))
})
}

Expand Down Expand Up @@ -258,7 +258,7 @@ func Test_mrCmd_DifferingUpstreamBranchName(t *testing.T) {
t.Log(string(b))
t.Fatal(err)
}
require.Contains(t, string(b), fmt.Sprintf("Merge Request #%s closed", mrID))
require.Contains(t, string(b), fmt.Sprintf("Merge Request !%s closed", mrID))
})
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/mr_thumb.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var mrThumbUpCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
fmt.Printf("Merge Request #%d thumb'd up\n", id)
fmt.Printf("Merge Request !%d thumb'd up\n", id)
},
}

Expand All @@ -63,7 +63,7 @@ var mrThumbDownCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
fmt.Printf("Merge Request #%d thumb'd down\n", id)
fmt.Printf("Merge Request !%d thumb'd down\n", id)
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/mr_unapprove.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var mrUnapproveCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
fmt.Printf("Merge Request #%d unapproved\n", id)
fmt.Printf("Merge Request !%d unapproved\n", id)
},
}

Expand Down

0 comments on commit c1bc35a

Please sign in to comment.