diff --git a/contrib/pulls/README.md b/contrib/pulls/README.md index 02fdb2d..89453ef 100644 --- a/contrib/pulls/README.md +++ b/contrib/pulls/README.md @@ -8,3 +8,5 @@ From the base directory ``` go run contrib/pulls/pulls.go --release 1.11.4 ``` + +To convert tea release posts, switch to tea mode via `--tea` flag. diff --git a/contrib/pulls/pulls.go b/contrib/pulls/pulls.go index b1d6fa3..cd85ad4 100644 --- a/contrib/pulls/pulls.go +++ b/contrib/pulls/pulls.go @@ -9,13 +9,16 @@ import ( ) var ( - pullURL = "https://github.com/go-gitea/gitea/pull/" - pullRegex = regexp.MustCompile(`#(\d+)\)`) + pullGiteaURL = "https://github.com/go-gitea/gitea/pull/" + pullTeaURL = "https://gitea.com/gitea/tea/pulls/" + pullRegex = regexp.MustCompile(`#(\d+)\)`) ) func main() { var release string + var tea bool flag.StringVar(&release, "release", "", "The release to target") + flag.BoolVar(&tea, "tea", false, "switch to tea mode") flag.Parse() if release == "" { @@ -23,7 +26,12 @@ func main() { return } - fi, err := os.OpenFile(fmt.Sprintf("content/post/release-of-%s.md", release), os.O_RDWR, os.ModePerm) + post := fmt.Sprintf("content/post/release-of-%s.md", release) + if tea { + post = fmt.Sprintf("content/post/release-of-tea-%s.md", release) + } + + fi, err := os.OpenFile(post, os.O_RDWR, os.ModePerm) if os.IsNotExist(err) { fmt.Printf("could not find content/post/release-of-%s.md\n", release) return @@ -39,6 +47,11 @@ func main() { return } + pullURL := pullGiteaURL + if tea { + pullURL = pullTeaURL + } + repl := pullRegex.ReplaceAll(data, []byte(`[#$1](`+pullURL+`$1))`)) if _, err := fi.WriteAt(repl, 0); err != nil { fmt.Println(err)