Use git go module
This commit is contained in:
37
src/main.go
37
src/main.go
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -127,34 +126,6 @@ func updateFiles(filePaths []string, oldVersion, newVersion string) {
|
||||
}
|
||||
}
|
||||
|
||||
// gitCommit выполняет коммит с внесёнными изменениями
|
||||
func gitCommit(currentVersion, newVersion string, bc *BumpConfig) error {
|
||||
commitMsg := strings.ReplaceAll(bc.Message, "{current_version}", currentVersion)
|
||||
commitMsg = strings.ReplaceAll(commitMsg, "{new_version}", newVersion)
|
||||
if bc.Commit {
|
||||
if err := exec.Command("git", "add", ".").Run(); err != nil {
|
||||
return fmt.Errorf("git add error: %w", err)
|
||||
}
|
||||
if err := exec.Command("git", "commit", "-m", commitMsg).Run(); err != nil {
|
||||
return fmt.Errorf("git commit error: %w", err)
|
||||
}
|
||||
log.Printf("Committed with message: %s", commitMsg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// gitTag ставит тэг на коммит
|
||||
func gitTag(currentVersion, newVersion string, bc *BumpConfig) error {
|
||||
if bc.Tag {
|
||||
tagName := strings.ReplaceAll(bc.TagName, "{new_version}", newVersion)
|
||||
if err := exec.Command("git", "tag", tagName).Run(); err != nil {
|
||||
return fmt.Errorf("git tag error: %w", err)
|
||||
}
|
||||
log.Printf("Created git tag: %s", tagName)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// updateConfigFile обновляет исходный конфигурационный файл
|
||||
func updateConfigFile(configPath string, newVersion string) error {
|
||||
cfg, err := ini.Load(configPath)
|
||||
@@ -238,16 +209,12 @@ func main() {
|
||||
|
||||
// Выполняем git commit и tag, если требуется
|
||||
if shouldCommit {
|
||||
if err := gitCommit(bc.CurrentVersion, newVersion, bc); err != nil {
|
||||
log.Printf("Git commit error: %v", err)
|
||||
}
|
||||
gitCommit(bc, newVersion)
|
||||
}
|
||||
|
||||
// Выполняем git commit и tag, если требуется
|
||||
if shouldTag {
|
||||
if err := gitTag(bc.CurrentVersion, newVersion, bc); err != nil {
|
||||
log.Printf("Git tag error: %v", err)
|
||||
}
|
||||
gitTag(bc, newVersion)
|
||||
}
|
||||
|
||||
// Обновляем конфигурационный файл
|
||||
|
||||
Reference in New Issue
Block a user