func (c Config) removeFailedBuildComment(repoName, job string, pr int) error { // parse git repo for username // and repo name r := strings.SplitN(repoName, "/", 2) if len(r) < 2 { return fmt.Errorf("repo name could not be parsed: %s", repoName) } // initialize github client g := github.GitHub{ AuthToken: c.GHToken, User: c.GHUser, } repo := octokat.Repo{ Name: r[1], UserName: r[0], } content, err := g.GetContent(repo, pr, true) if err != nil { return fmt.Errorf("getting pull request content failed: %v", err) } // find the comments about failed builds and remove them if comment := content.FindComment(fmt.Sprintf("Job: %s [FAILED", job), c.GHUser); comment != nil { if err := g.Client().RemoveComment(repo, comment.Id); err != nil { return fmt.Errorf("removing comment from %s#%d for %s failed: %v", repoName, pr, job, err) } } return nil }