-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
todo: Implmement 'mr' and 'issue' commands
The GitLab WebUI allows users to mark add Todo list items from a Merge Request pages and Issue pages. Unfortunately the go-gitlab library does not implenet the adding of Issues to Todo lists [1]. Implement a "mr" command that allows users to add Merge Requests as Todo list items. Since go-gitlab does not support the adding of Issues to Todo lists so put in a place holder for an "issue" command. Signed-off-by: Prarit Bhargava <[email protected]> [1] xanzy/go-gitlab#1130
- Loading branch information
Showing
4 changed files
with
117 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cmd | ||
|
||
import ( | ||
"log" | ||
"strconv" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var todoIssueCmd = &cobra.Command{ | ||
Use: "issue", | ||
Short: "Add a Issue to Todo list", | ||
Example: `lab todo issue 5678 #adds Issue 1234 to user's Todo list`, | ||
Hidden: true, | ||
Long: ``, | ||
PersistentPreRun: LabPersistentPreRun, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
rn, err := getRemoteName("") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
num, err := strconv.Atoi(args[0]) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
todoAddIssue(rn, num) | ||
|
||
}, | ||
} | ||
|
||
func todoAddIssue(project string, issueNum int) { | ||
// https://github.com/xanzy/go-gitlab/pull/1130 | ||
log.Fatal("Adding issues not implemented.") | ||
} | ||
|
||
func init() { | ||
todoCmd.AddCommand(todoIssueCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"strconv" | ||
|
||
"github.com/spf13/cobra" | ||
lab "github.com/zaquestion/lab/internal/gitlab" | ||
) | ||
|
||
var todoMRCmd = &cobra.Command{ | ||
Use: "mr", | ||
Short: "Add a Merge Request to Todo list", | ||
Example: `lab todo mr 1234 #adds MR 1234 to user's Todo list`, | ||
Long: ``, | ||
PersistentPreRun: LabPersistentPreRun, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
rn, err := getRemoteName("") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
num, err := strconv.Atoi(args[0]) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
todoAddMergeRequest(rn, num) | ||
}, | ||
} | ||
|
||
func todoAddMergeRequest(remote string, mrNum int) { | ||
todoID, err := lab.TodoMRCreate(remote, mrNum) | ||
if err != nil { | ||
if err == lab.ErrNotModified { | ||
log.Fatalf("Todo entry already exists for MR !%d", mrNum) | ||
} | ||
log.Fatal(err) | ||
} | ||
|
||
mr, err := lab.MRGet(remote, mrNum) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Println(todoID, mr.WebURL) | ||
} | ||
|
||
func init() { | ||
todoCmd.AddCommand(todoMRCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters