Skip to content
Snippets Groups Projects
Select Git revision
  • ecb9f480418352aca43e14cf0f661f6aefeefc1c
  • main default protected
  • 1-mage-run-does-not-stop-containers
  • v0.26.0
  • v0.25.0
  • v0.24.0
  • v0.23.0
  • v0.22.0
  • v0.21.0
  • v0.20.0
  • v0.19.0
  • v0.18.0
  • v0.17.0
  • v0.16.0
  • v0.15.0
  • v0.14.0
  • v0.13.0
  • v0.12.0
  • v0.11.0
  • v0.10.0
  • v0.9.0
  • v0.8.0
  • v0.7.0
23 results

git.go

Blame
  • git.go 1.84 KiB
    package mage_helpers
    
    import (
    	"fmt"
    	"os/exec"
    	"strings"
    	"github.com/Masterminds/semver"
    )
    
    func HasChanges(previousCommit string, folder string) bool {
    	fmt.Println(fmt.Sprintf("Comparing changes from: %v for %v", previousCommit, folder))
    	commandArgs := []string{
    		`diff`,
    		`--name-only`,
    		previousCommit + `..HEAD`,
    		folder,
    	}
    
    	cmd := exec.Command("git", commandArgs...)
    	output, err := cmd.CombinedOutput()
    	if err != nil {
    		fmt.Println(err)
    	}
    	changes := strings.Fields(string(output))
    	if len(changes) > 0 {
    		fmt.Println(fmt.Sprintf("Has %v changes", folder))
    		return true
    	}
    	fmt.Println("No changes")
    	return false
    }
    
    func CurrentCommit() string {
    
    	commandArgs := []string{
    		`rev-parse`,
    		`--short`,
    		`HEAD`,
    	}
    	cmd := exec.Command("git", commandArgs...)
    	output, err := cmd.CombinedOutput()
    	if err != nil {
    		fmt.Println(err)
    	}
    	return string(output)
    }
    
    func CreateReleaseTag() {
    
    	// Get version and increase version number
    	previousVersion, err := semver.NewVersion(GetLatestGitTag())
    	if err != nil {
    		fmt.Println(err)
    	}
    	fmt.Println(previousVersion)
    
    	newVersion := previousVersion.IncMinor()
    	fmt.Println(newVersion)
    
    	// Create git tag
    	newTagName := newVersion.Original()
    	commandArgs := []string{
    		`tag`,
    		newTagName,
    	}
    	cmd := exec.Command("git", commandArgs...)
    	_, err = cmd.CombinedOutput()
    	if err != nil {
    		fmt.Println(err)
    	}