Skip to content

Commit

Permalink
just list merge request and source branch
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinDelille committed Sep 26, 2018
1 parent 82c6531 commit 7f96c8f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/mr_browse.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package cmd

import (
"fmt"
"log"
"net/url"
"path"
"strconv"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/xanzy/go-gitlab"
lab "github.com/zaquestion/lab/internal/gitlab"
)

var mrBrowseCmd = &cobra.Command{
Expand All @@ -32,6 +35,22 @@ var mrBrowseCmd = &cobra.Command{
hostURL.Path = path.Join(hostURL.Path, rn, "merge_requests")
if num > 0 {
hostURL.Path = path.Join(hostURL.Path, strconv.FormatInt(num, 10))
} else {
mrs, err := lab.MRList(rn, gitlab.ListProjectMergeRequestsOptions{
ListOptions: gitlab.ListOptions{
PerPage: 10,
},
Labels: mrLabels,
State: &mrState,
OrderBy: gitlab.String("updated_at"),
SourceBranch: gitlab.String("browse-current-mr"),
}, -1)
if err != nil {
log.Fatal(err)
}
for _, mr := range mrs {
fmt.Printf("#%d %s\n", mr.IID, mr.Title, mr.SourceBranch)
}
}

err = browse(hostURL.String())
Expand Down

0 comments on commit 7f96c8f

Please sign in to comment.