Documentation ¶
Index ¶
- Constants
- Variables
- func Add(args ...string) error
- func Branch(args ...string) error
- func BranchHexsha(branch string) (hexsha string, err error)
- func CheckOrCreateTrackingBranch(branch, remote string) error
- func Checkout(args ...string) error
- func CherryPick(args ...string) error
- func CoreBranchHashes() (map[string]string, error)
- func CreateOrResetBranch(branch, target string) (action.Action, error)
- func CreateTrackingBranch(branch, remote string) error
- func DeleteTag(tag string) error
- func EnsureBranchNotExist(branch string, remote string) error
- func EnsureBranchSynchronized(branch, remote string) (err error)
- func EnsureCleanWorkingTree(includeUntracked bool) error
- func EnsureFileClean(relativePath string) error
- func FixCommitSources(commits []*Commit) error
- func GetConfigString(key string) (value string, err error)
- func Hexsha(ref string) (hexsha string, err error)
- func IsBranchSynchronized(branch, remote string) (bool, error)
- func IsCoreBranch(branch string) (bool, error)
- func LocalBranchExists(branch string) (exists bool, err error)
- func Log(args ...string) (stdout *bytes.Buffer, err error)
- func Merge(args ...string) error
- func Push(remote string, args ...string) error
- func PushForce(remote string, args ...string) error
- func Rebase(args ...string) error
- func RefExists(ref string) (exists bool, err error)
- func RefExistsStrict(ref string) (exists bool, err error)
- func RemoteBranchExists(branch string, remote string) (exists bool, err error)
- func Reset(args ...string) error
- func RevisionsToCommitList(revisions ...string) ([]string, error)
- func Run(args ...string) (stdout *bytes.Buffer, err error)
- func RunCommand(command string, args ...string) (stdout *bytes.Buffer, err error)
- func SetBranch(branch, targetRef string) error
- func SetConfigString(key string, value string) error
- func Status(args ...string) (stdout *bytes.Buffer, err error)
- func Tag(args ...string) error
- func UpdateRemotes(remotes ...string) error
- type Commit
- func FilterCommits(commits []*Commit, filterFunc CommitFilterFunc) []*Commit
- func GrepCommitsCaseInsensitive(filter string, args ...string) ([]*Commit, error)
- func ParseCommits(input []byte) (commits []*Commit, err error)
- func ShowCommitRange(revisionRange string) ([]*Commit, error)
- func ShowCommits(revisions ...string) ([]*Commit, error)
- type CommitFilterFunc
- type Config
- type ErrDirtyFile
- type ErrRefNotFound
- type ErrRefNotInSync
- type GitBranch
- type LocalConfig
Constants ¶
const ConfigKey = "salsaflow.core.git"
const DefaultRemoteName = "origin"
const GitConfigKeyRemote = "salsaflow.remote"
const StoryIdUnassignedTagValue = "unassigned"
const ZeroHash = "0000000000000000000000000000000000000000"
Variables ¶
var ( ChangeIdTagPattern = regexp.MustCompile("^(?i)[ \t]*Change-Id:[ \t]+([^ \t]+)") StoryIdTagPattern = regexp.MustCompile("^(?i)[ \t]*Story-Id:[ \t]+([^ \t]+)") )
var ErrDirtyRepository = errors.New("the repository is dirty")
Functions ¶
func BranchHexsha ¶ added in v0.7.0
func CheckOrCreateTrackingBranch ¶ added in v0.9.0
CheckOrCreateTrackingBranch tries to make sure that a local branch of the given name exists and is in sync with the given remote.
So, in case the right remote branch exists and the local does not, the local tracking branch is created. In case the local branch exists already, it is ensured that it is up to date.
In case the remote branch does not exist, *ErrRefNotFound is returned. In case the branch is not up to date, *ErrRefNotInSync is returned.
func CherryPick ¶
func CoreBranchHashes ¶ added in v0.7.0
CoreBranchHashes returns a map containing all core branches with their hashes, i.e. map[branchName]commitHash.
func CreateTrackingBranch ¶ added in v0.19.0
func EnsureBranchNotExist ¶
func EnsureBranchSynchronized ¶
EnsureBranchSynchronized makes sure the given branch is up to date. If that is not the case, *ErrRefNoInSync is returned.
func EnsureCleanWorkingTree ¶
func EnsureFileClean ¶
func FixCommitSources ¶
FixCommitSources can be used to set the Source field for the given commits to the right value in respect to the branching model.
We need this function becase using git log --all --source actually does not always yield the source values we want. It can set the source for the commits on the trunk branch and on the release branch to one of the feature branches that are branched off the given branch. That is not what we want, we want to have the Source field set to the trunk branch or the release branch in case the commit is reachable from one of these branches.
More precisely, the Source field is set in the following way:
commits on trunk -> refs/heads/trunk commits on trunk..origin/trunk -> refs/remotes/origin/trunk commits on trunk..release -> refs/heads/release commits on origin/trunk..origin/release -> refs/remotes/origin/release
func GetConfigString ¶
func IsBranchSynchronized ¶ added in v0.7.0
IsBranchSynchronized returns true when the branch of the given name is up to date with the given remote. In case the branch does not exist in the remote repository, true is returned as well.
func IsCoreBranch ¶ added in v0.7.0
func LocalBranchExists ¶
func RefExistsStrict ¶
RefExistsStrict requires the whole ref path to be specified, e.g. refs/remotes/origin/master.
func RemoteBranchExists ¶
func RevisionsToCommitList ¶ added in v0.20.0
RevisionsToCommitList uses git rev-list --no-walk to turn given list of revision specifications into a list of commits.
The list is passed to git rev-list --no-walk unchanges, so check the docs to understand the exact behaviour of this function.
func SetConfigString ¶
func UpdateRemotes ¶
Types ¶
type Commit ¶
type Commit struct { SHA string Source string Merge string Author string AuthorDate time.Time Committer string CommitDate time.Time MessageTitle string Message string ChangeIdTag string StoryIdTag string }
func FilterCommits ¶ added in v0.9.0
func FilterCommits(commits []*Commit, filterFunc CommitFilterFunc) []*Commit
FilterCommits can be used to filter commits by the given filter function.
func ParseCommits ¶
Parse git log output, which is a sequence of Git commits looking like
commit $hexsha $source Author: $author Date: $date
$title $body Change-Id: $changeId Story-Id: $storyId
The reason why we are parsing the regular output (not using --pretty=format:) is that not all formatting options are supported. For example, log --all --source contains some information that cannot be easily taken by using --pretty=format:
func ShowCommitRange ¶
ShowCommitRange returns the list of commits specified by the given Git revision range.
func ShowCommits ¶
ShowCommits returns the commit objects specified by the given revisions.
Revision ranges can be used as well, the revision list is simply passed to git show, so check the associated docs.
type CommitFilterFunc ¶ added in v0.9.0
type Config ¶
type Config struct { LocalConfig RemoteName string }
Config holds the complete Git-related config needed by SalsaFlow.
func LoadConfig ¶
LoadConfig can be used to load Git-related configuration for SalsaFlow.
type ErrDirtyFile ¶
type ErrDirtyFile struct {
RelativePath string
}
func (*ErrDirtyFile) Error ¶
func (err *ErrDirtyFile) Error() string
type ErrRefNotFound ¶ added in v0.9.0
type ErrRefNotFound struct {
Ref string
}
func (*ErrRefNotFound) Error ¶ added in v0.9.0
func (err *ErrRefNotFound) Error() string
type ErrRefNotInSync ¶ added in v0.11.0
type ErrRefNotInSync struct {
Ref string
}
func (*ErrRefNotInSync) Error ¶ added in v0.11.0
func (err *ErrRefNotInSync) Error() string
type GitBranch ¶ added in v0.13.0
type GitBranch struct { // Local branch name BranchName string // Name of the remote branch being tracked RemoteBranchName string // Name of remote the remote branch is associated with Remote string }
Branch represents a Git branch.
func (*GitBranch) CanonicalName ¶ added in v0.13.0
CanonicalName returns
"{{.BranchName}}" in case it is not empty, and "{{.Remote}}/{{.RemoteBranchName}}" otherwise.
func (*GitBranch) FullRemoteBranchName ¶ added in v0.13.0
FullRemoteName returns "{{.Remote}}/{{.RemoteBranchName}}".
func (*GitBranch) IsUpToDate ¶ added in v0.13.0
IsUpToDate returns true when the local and remote references point to the same commit.
type LocalConfig ¶
type LocalConfig struct { TrunkBranchName string `prompt:"trunk branch name" default:"develop" json:"trunk_branch"` ReleaseBranchName string `prompt:"release branch name" default:"release" json:"release_branch"` StagingBranchName string `prompt:"staging branch name" default:"stage" json:"staging_branch"` StableBranchName string `prompt:"stable branch name" default:"master" json:"stable_branch"` }
LocalConfig implements loader.ConfigContainer interface.
func (*LocalConfig) PromptUserForConfig ¶ added in v0.16.0
func (local *LocalConfig) PromptUserForConfig() error
PromptUserForConfig is a part of loader.ConfigContainer interface.