[arvados-dev] updated: da93424ea7dc5314834e089026f6d06a89412cc8

git repository hosting git at public.arvados.org
Fri Apr 5 20:21:34 UTC 2024


Summary of changes:
 cmd/art/redmine.go    | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/redmine/issues.go | 14 ++++++++++++
 2 files changed, 75 insertions(+)

       via  da93424ea7dc5314834e089026f6d06a89412cc8 (commit)
      from  e172b06c0080c34b8d110675bda710011567de17 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit da93424ea7dc5314834e089026f6d06a89412cc8
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Fri Apr 5 16:20:37 2024 -0400

    Add set-sprint subcommand to 'art', no issue #
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/cmd/art/redmine.go b/cmd/art/redmine.go
index 1ad293b..a170a6e 100644
--- a/cmd/art/redmine.go
+++ b/cmd/art/redmine.go
@@ -44,6 +44,19 @@ func init() {
 	}
 	issuesCmd.AddCommand(associateIssueCmd)
 
+
+	setIssueSprintCmd.Flags().IntP("sprint", "r", 0, "Redmine sprint ID")
+	err = setIssueSprintCmd.MarkFlagRequired("sprint")
+	if err != nil {
+		log.Fatalf(err.Error())
+	}
+	setIssueSprintCmd.Flags().IntP("issue", "i", 0, "Redmine issue ID")
+	err = setIssueSprintCmd.MarkFlagRequired("issue")
+	if err != nil {
+		log.Fatalf(err.Error())
+	}
+	issuesCmd.AddCommand(setIssueSprintCmd)
+
 	associateOrphans.Flags().IntP("release", "r", 0, "Redmine release ID")
 	err = associateOrphans.MarkFlagRequired("release")
 	if err != nil {
@@ -312,6 +325,54 @@ var associateIssueCmd = &cobra.Command{
 	},
 }
 
+
+var setIssueSprintCmd = &cobra.Command{
+	Use:   "set-sprint",
+	Short: "Set sprint for issue",
+	Long: "Set the sprint for an issue.\n" +
+		"\nThe REDMINE_ENDPOINT environment variable must be set to the base URL of your redmine server." +
+		"\nThe REDMINE_APIKEY environment variable must be set to your redmine API key.",
+	Run: func(cmd *cobra.Command, args []string) {
+		issueID, err := cmd.Flags().GetInt("issue")
+		if err != nil {
+			fmt.Printf("Error converting Redmine issue ID to integer: %s", err)
+			os.Exit(1)
+		}
+
+		sprintID, err := cmd.Flags().GetInt("sprint")
+		if err != nil {
+			fmt.Printf("Error converting Redmine sprint ID to integer: %s", err)
+			os.Exit(1)
+		}
+
+		redmine := redmine.NewClient(conf.Endpoint, conf.Apikey)
+
+		i, err := redmine.GetIssue(issueID)
+		if err != nil {
+			fmt.Printf("%s\n", err.Error())
+			os.Exit(1)
+		}
+
+		var setIt bool
+		if i.FixedVersion == nil {
+			setIt = true
+		} else if i.FixedVersion.ID != sprintID {
+			setIt = true
+		}
+		if setIt {
+			err = redmine.SetSprint(*i, sprintID)
+			if err != nil {
+				fmt.Printf("%s\n", err.Error())
+				os.Exit(1)
+			} else {
+				fmt.Printf("[changed] sprint for issue %d set to %d\n", i.ID, sprintID)
+			}
+		} else {
+			fmt.Printf("[ok] sprint for issue %d was already set to %d, not updating\n", i.ID, i.FixedVersion.ID)
+		}
+	},
+}
+
 func checkError(err error) {
 	if err != nil {
 		fmt.Printf("%s\n", err.Error())
diff --git a/lib/redmine/issues.go b/lib/redmine/issues.go
index ea2f584..5e02272 100644
--- a/lib/redmine/issues.go
+++ b/lib/redmine/issues.go
@@ -233,3 +233,17 @@ func (c *Client) SetRelease(issue Issue, release int) error {
 	issue.Release = nil
 	return c.UpdateIssue(issue)
 }
+
+// SetSprint updates the sprint (fixed_version) for an issue
+func (c *Client) SetSprint(issue Issue, version int) error {
+	issue.FixedVersionID = version
+	issue.FixedVersion = nil
+	return c.UpdateIssue(issue)
+}
+
+// SetStatus updates the status for an issue
+func (c *Client) SetStatus(issue Issue, status int) error {
+	issue.StatusID = status
+	issue.Status = nil
+	return c.UpdateIssue(issue)
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list