add(gitea-api): issue and milestone updating
This implements the api patches for updating an issue or milestone for a given repository and issue or milestone. WIP for #1.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package gitea
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -53,3 +54,21 @@ func (gitea *Gitea) GetMilestone(repo Repository, id uint) (Milestone, error) {
|
||||
}
|
||||
return milestone, nil
|
||||
}
|
||||
|
||||
func (gitea *Gitea) UpdateMilestone(repo Repository, milestone Milestone) error {
|
||||
url := fmt.Sprintf("%s/repos/%s/milestones/%d", gitea.Url(), repo.Full_name, milestone.Id)
|
||||
var payload map[string]interface{}
|
||||
payload["description"] = milestone.Description
|
||||
payload["due_on"] = milestone.Due_on
|
||||
payload["state"] = milestone.State
|
||||
payload["title"] = milestone.Title
|
||||
json, err := json.Marshal(&payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = http.NewRequest(http.MethodPatch, url, bytes.NewBuffer(json))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user