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 CurrentBranch() (branch string, err error)
- func DeleteTag(tag string) error
- func EnsureBranchNotExist(branch string, remote string) error
- func EnsureBranchSynchronized(branch, remote string) 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 ParseUpstreamURL() (owner, repo string, err 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 ResetKeep(branch, ref string) (err error)
- func Run(args ...string) (stdout *bytes.Buffer, err error)
- func RunCommand(command string, args ...string) (stdout *bytes.Buffer, err 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 LocalConfig
Constants ¶
const ( DefaultRemoteName = "origin" DefaultTrunkBranchName = "develop" DefaultReleaseBranchName = "release" DefaultStageBranchName = "stage" DefaultStableBranchName = "master" )
const ConfigKeyRemote = "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.
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 CurrentBranch ¶
func EnsureBranchNotExist ¶
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 release..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 ParseUpstreamURL ¶ added in v0.10.0
ParseUpstreamURL parses the URL of the git upstream being used by SalsaFlow and returns the given GitHub owner and repository.
func RefExistsStrict ¶
RefExistsStrict requires the whole ref path to be specified, e.g. refs/remotes/origin/master.
func RemoteBranchExists ¶
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 list of commits associated with the given revisions.
type CommitFilterFunc ¶ added in v0.9.0
type Config ¶
type Config interface { RemoteName() string TrunkBranchName() string ReleaseBranchName() string StagingBranchName() string StableBranchName() string }
func LoadConfig ¶
type ErrDirtyFile ¶
type ErrDirtyFile struct {
// contains filtered or unexported fields
}
func (*ErrDirtyFile) Error ¶
func (err *ErrDirtyFile) Error() string
type ErrRefNotFound ¶ added in v0.9.0
type ErrRefNotFound struct {
// contains filtered or unexported fields
}
func (*ErrRefNotFound) Error ¶ added in v0.9.0
func (err *ErrRefNotFound) Error() string
func (*ErrRefNotFound) Ref ¶ added in v0.9.0
func (err *ErrRefNotFound) Ref() string