From f513a8d1307dd2188fc3f0708b0b5241b144dd30 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Wed, 12 May 2021 15:46:01 +0200 Subject: [PATCH] feat: Add function for backing up sources Signed-off-by: Matej Focko --- main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 13e6934..de7b9ca 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "bufio" "fmt" + "io" "os" "sort" @@ -68,7 +69,18 @@ func printComments(wrapper *wrap.Wrapper, commentsByFile map[string]([]*gitea.Pu } } -func patchFiles(wrapper *wrap.Wrapper, commentsByFile map[string]([]*gitea.PullReviewComment)) { +func BackUpSource(filepath string) { + inputFile, err := os.Open(filepath) + ExitOnError(err) + defer inputFile.Close() + + BackUpSourceFile, err := os.Create(filepath + ".bck") + ExitOnError(err) + defer BackUpSourceFile.Close() + + _, err = io.Copy(BackUpSourceFile, inputFile) + ExitOnError(err) +} for filepath, comments := range commentsByFile { fmt.Printf("FILE: %s\n", filepath)