Add initial version of the sync command

This commit is contained in:
Miguel de la Cruz 2020-09-21 09:27:50 +02:00
parent f0d4dfb962
commit a13a0ec949
3 changed files with 42 additions and 11 deletions

View file

@ -128,3 +128,27 @@ func (a *App) PublishBatchInGithub(batch int, dryRun bool) error {
}
return nil
}
func (a *App) GithubSync() error {
tickets := a.Campaign.GetPublishedGithubTickets()
total := len(tickets)
owner, repo := a.Campaign.RepoComponents()
for i, ticket := range tickets {
fmt.Printf("\rUpdating ticket %d of %d", i+1, total)
issue, _, err := a.GithubClient.Issues.Get(context.Background(), owner, repo, ticket.GithubLink)
if err != nil {
return err
}
assignee := issue.GetAssignee()
if assignee != nil {
ticket.GithubAssignee = assignee.GetLogin()
}
ticket.GithubStatus = issue.GetState()
}
fmt.Print("\n")
return a.Save()
}