internal

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetHooksPath = func() string {
	return ".git/hooks"
}

GetHooksPath returns the path to the git hooks directory This can be overridden in tests

View Source
var InstallHooks = func(config *Config) error {
	hooksPath := GetHooksPath()
	hooks := map[string]string{
		"commit-msg":    getBinaryPath(config, "commitmsg"),
		"post-checkout": getBinaryPath(config, "postco"),
	}

	for hookName, binaryPath := range hooks {
		hookPath := filepath.Join(hooksPath, hookName)
		if err := os.Symlink(binaryPath, hookPath); err != nil && !os.IsExist(err) {
			return fmt.Errorf("failed to install %s hook: %w", hookName, err)
		}
	}
	return nil
}

Make InstallHooks mockable for testing

Functions

func CLIMenu

func CLIMenu(
	config *Config,
) *cobra.Command

func CheckGitAndHooksDir

func CheckGitAndHooksDir() error

func CheckStatus added in v0.4.0

func CheckStatus(config *Config)

func ExecuteCommand

func ExecuteCommand(command string, args ...string) (string, error)

func ExecuteGitCommand

func ExecuteGitCommand(args ...string) (string, error)

Function to execute git commands

func GetCurrentBranchName

func GetCurrentBranchName() (string, error)

func GetGlobalBinPath

func GetGlobalBinPath() (string, error)

func IsJiraFlowActive added in v0.4.0

func IsJiraFlowActive() bool

func RemoveGitHooks added in v0.3.0

func RemoveGitHooks(hookPath string) error

func RemoveHooks added in v0.4.0

func RemoveHooks(config *Config) error

func SetCommitMsgHook added in v0.2.0

func SetCommitMsgHook(config *Config) error

func SetGitHooks added in v0.2.0

func SetGitHooks(config *Config) error

configures all necessary Git hooks

func SetPostCheckoutHook added in v0.2.0

func SetPostCheckoutHook(config *Config) error

func ToggleJiraFlow added in v0.4.0

func ToggleJiraFlow(config *Config, enable bool) error

Types

type Config

type Config struct {
	AutoLink      bool   // Enable automatic JIRA key linking from branch name
	JiraKey       string // Default JIRA key if provided
	BranchPattern string // The pattern to use for matching JIRA keys in branch names
	HookPath      string // Path to the Git hooks directory
}

func NewConfig

func NewConfig() *Config

New returns a new Config instance with default settings.

type JiraManager

type JiraManager struct {
	Config *Config
}

JiraManager handles operations related to JIRA issues.

func NewJiraManager

func NewJiraManager(config *Config) *JiraManager

NewJiraManager creates a new instance of JiraManager with the provided configuration.

func (*JiraManager) ConfigureAutomatic added in v0.5.0

func (jm *JiraManager) ConfigureAutomatic() error

ConfigureAutomatic sets up automatic JIRA issue key extraction from branch names

func (*JiraManager) ExtractIssueKeyFromBranchName

func (jm *JiraManager) ExtractIssueKeyFromBranchName(branchName string) (string, error)

func (*JiraManager) ValidateJiraKey

func (jm *JiraManager) ValidateJiraKey(
	input string,
) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳