Skip to content
Snippets Groups Projects
Select Git revision
  • 85bd54fd8693f0986a592a2d153f37777ae9d310
  • dev default protected
  • prod protected
  • 1.0.58
  • 1.0.57
  • 1.0.52
  • 1.0.56
  • 1.0.51
  • 1.0.50
  • 1.0.33
  • 1.0.32
  • 1.0.31
  • 1.0.30
  • 1.0.29
  • 1.0.28
  • 1.0.27
  • 1.0.26
  • 1.0.25
  • 1.0.24
  • 1.0.23
  • 1.0.22
  • 1.0.21
  • 1.0.20
23 results

UData.php

Blame
  • git.go 1.77 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)
    	}
    
    	newVersion := previousVersion.IncMinor()
    
    	// Create git tag
    	newTagName := newVersion.Original()
    	commandArgs := []string{
    		`tag`,
    		newTagName,
    	}
    	cmd := exec.Command("git", commandArgs...)
    	_, err = cmd.CombinedOutput()
    	if err != nil {
    		fmt.Println(err)
    	}
    
    	// Push new tag