From 90800cfb675ac50a8506db3d9a222b09a5cbdf98 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sat, 11 Dec 2021 23:26:09 +0100 Subject: [PATCH] refactor: Factor out patching to separate function Signed-off-by: Matej Focko --- src/cmd/patch.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cmd/patch.go b/src/cmd/patch.go index 50525df..ca33a20 100644 --- a/src/cmd/patch.go +++ b/src/cmd/patch.go @@ -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