pr-resolution #3
2 changed files with 35 additions and 27 deletions
27
main.go
27
main.go
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
@ -11,19 +10,6 @@ import (
|
|||
"code.gitea.io/sdk/gitea"
|
||||
)
|
||||
|
||||
type ByLineNum []*gitea.PullReviewComment
|
||||
|
||||
func (a ByLineNum) Len() int { return len(a) }
|
||||
func (a ByLineNum) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByLineNum) Less(i, j int) bool { return a[i].LineNum < a[j].LineNum }
|
||||
|
||||
func ExitOnError(err error) {
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func RetrieveComments(client *gitea.Client, prID, reviewID int64) []*gitea.PullReviewComment {
|
||||
comments, _, err := client.ListPullReviewComments(
|
||||
config.Gitea.Owner, config.Gitea.Repository, prID, reviewID,
|
||||
|
@ -49,19 +35,6 @@ func SplitByFile(
|
|||
return splitComments
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func WriteCommentsInFile(
|
||||
outputFile *os.File,
|
||||
lineNum uint64,
|
||||
|
|
35
utils.go
Normal file
35
utils.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
)
|
||||
|
||||
type ByLineNum []*gitea.PullReviewComment
|
||||
|
||||
func (a ByLineNum) Len() int { return len(a) }
|
||||
func (a ByLineNum) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByLineNum) Less(i, j int) bool { return a[i].LineNum < a[j].LineNum }
|
||||
|
||||
func ExitOnError(err error) {
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
Loading…
Reference in a new issue