refactor: Factor out patching to separate function

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2021-12-11 23:26:09 +01:00
parent 171411f13a
commit 90800cfb67
No known key found for this signature in database
GPG key ID: 332171FADF1DB90B

View file

@ -30,9 +30,7 @@ var (
err = GetPrID(client, &prID)
core.ExitOnError("Couldn't get PR ID", err)
comments := core.GetComments(&config, client, prID)
core.ProcessComments(&config, &comments)
PatchFiles(comments)
WriteReview(client, prID)
},
}
)
@ -42,6 +40,12 @@ func init() {
patchCmd.Flags().StringVarP(&branch, "branch", "b", "", "specifies branch where the review is present")
}
func WriteReview(client *gitea.Client, prID int64) {
comments := core.GetComments(&config, client, prID)
core.ProcessComments(&config, &comments)
PatchFiles(comments)
}
func GetPrID(client *gitea.Client, prID *int64) error {
if *prID != -1 {
return nil