Documentation
¶
Overview ¶
gitutil package provides utility functions for working with git repositories. To execute git operations we use the go-git library. However the library does not support all git operations and in those cases we directly run git commands. The utility functions in this file directly run git commands.
Index ¶
- Variables
- func Clone(ctx context.Context, path string, c *Config) (*git.Repository, error)
- func CloneRepo(repoURL string) (string, error)
- func CommitAndPush(ctx context.Context, projectPath string, config *Config, commitMsg string, ...) error
- func GitFetch(ctx context.Context, path string, config *Config) error
- func InferGitRepoRoot(path string) (string, error)
- func InferRepoRootAndSubpath(path string) (string, string, error)
- func IsGitRepo(path string) bool
- func NativeGitSignature(ctx context.Context, path string) (*object.Signature, error)
- func NormalizeGithubRemote(remote string) (string, error)
- func RunGitFetch(ctx context.Context, path, remote string) error
- func RunGitPull(ctx context.Context, path string, discardLocal bool, remote, remoteName string) (string, error)
- func RunGitPush(ctx context.Context, path, remoteName, branchName string) error
- func RunUpstreamMerge(ctx context.Context, remote, path, branch string, favourLocal bool) error
- func SetRemote(path string, config *Config) error
- func SplitGithubRemote(remote string) (account, repo string, ok bool)
- type Config
- type GitStatus
- type Remote
Constants ¶
This section is empty.
Variables ¶
var ( ErrGitRemoteNotFound = errors.New("no git remotes found") ErrNotAGitRepository = errors.New("not a git repository") )
Functions ¶
func CommitAndPush ¶ added in v0.78.0
func InferGitRepoRoot ¶ added in v0.78.0
func InferRepoRootAndSubpath ¶ added in v0.78.0
InferRepoRootAndSubpath infers the root of the Git repository and the subpath from the given path. Since the extraction stops at first .git directory it means that if a subpath in a github monorepo is deployed as a rill managed project it will prevent the subpath from being inferred. This means : - user will need to explicitly set the subpath if they want to connect this to Github. - When finding matching projects it will only list the rill managed projects for that subpath.
func NativeGitSignature ¶ added in v0.78.0
func NormalizeGithubRemote ¶ added in v0.78.0
NormalizeGithubRemote validates and converts a Git remote to a normalized HTTPS Github URL ending in .git.
func RunGitFetch ¶ added in v0.78.0
func RunGitPull ¶ added in v0.78.0
func RunGitPull(ctx context.Context, path string, discardLocal bool, remote, remoteName string) (string, error)
RunGitPull runs a git pull command in the specified path.
func RunGitPush ¶ added in v0.78.0
func RunUpstreamMerge ¶ added in v0.78.0
func SetRemote ¶ added in v0.78.0
SetRemote sets the remote by name Rill for the given repository to the provided remote URL.
func SplitGithubRemote ¶ added in v0.78.0
SplitGithubRemote splits a GitHub remote URL into a Github account and repository name.
Types ¶
type Config ¶ added in v0.64.1
type Config struct {
Remote string
Username string
Password string
PasswordExpiresAt time.Time
DefaultBranch string
Subpath string
ManagedRepo bool
}
func (*Config) FullyQualifiedRemote ¶ added in v0.78.0
func (*Config) RemoteName ¶ added in v0.78.0
type GitStatus ¶ added in v0.78.0
type GitStatus struct {
Branch string
RemoteURL string
LocalChanges bool // true if there are local changes (staged, unstaged, or untracked)
LocalCommits int32
RemoteCommits int32
}
func RunGitStatus ¶ added in v0.78.0
type Remote ¶ added in v0.22.0
Remote represents a Git remote with its name and URL. The URL is normalized to a HTTPS URL with a .git suffix.
func ExtractGitRemote ¶ added in v0.24.0
ExtractGitRemote extracts the first Git remote from the Git repository at projectPath. If remoteName is provided, it will return the remote with that name. If detectDotGit is true, it will look for a .git directory in parent directories.
func ExtractRemotes ¶ added in v0.22.0
ExtractRemotes extracts all Git remotes from the Git repository at projectPath. The returned remotes are normalized with NormalizeGithubRemote. If detectDotGit is true, it will look for a .git directory in parent directories.