Example #1
0
func LsRemote(remote, remoteRef string) (string, error) {
	if remote == "" {
		return "", errors.New("remote required")
	}
	if remoteRef == "" {
		return subprocess.SimpleExec("git", "ls-remote", remote)

	}
	return subprocess.SimpleExec("git", "ls-remote", remote, remoteRef)
}
Example #2
0
// UnsetLocalKey removes the git config value for the key from the specified config file
func (c *gitConfig) UnsetLocalKey(file, key string) {
	args := make([]string, 1, 5)
	args[0] = "config"
	if len(file) > 0 {
		args = append(args, "--file", file)
	}
	args = append(args, "--unset", key)
	subprocess.SimpleExec("git", args...)
}
Example #3
0
// SetLocal sets the git config value for the key in the specified config file
func (c *gitConfig) SetLocal(file, key, val string) (string, error) {
	args := make([]string, 1, 5)
	args[0] = "config"
	if len(file) > 0 {
		args = append(args, "--file", file)
	}
	args = append(args, key, val)
	return subprocess.SimpleExec("git", args...)
}
Example #4
0
// Version returns the git version
func (c *gitConfig) Version() (string, error) {
	c.mu.Lock()
	defer c.mu.Unlock()

	if len(c.gitVersion) == 0 {
		v, err := subprocess.SimpleExec("git", "version")
		if err != nil {
			return v, err
		}
		c.gitVersion = v
	}

	return c.gitVersion, nil
}
Example #5
0
func ResolveRef(ref string) (*Ref, error) {
	outp, err := subprocess.SimpleExec("git", "rev-parse", ref, "--symbolic-full-name", ref)
	if err != nil {
		return nil, err
	}
	lines := strings.Split(outp, "\n")
	if len(lines) <= 1 {
		return nil, fmt.Errorf("Git can't resolve ref: %q", ref)
	}

	fullref := &Ref{Sha: lines[0]}
	fullref.Type, fullref.Name = ParseRefToTypeAndName(lines[1])
	return fullref, nil
}
Example #6
0
func ResolveRef(ref string) (*Ref, error) {
	outp, err := subprocess.SimpleExec("git", "rev-parse", ref, "--symbolic-full-name", ref)
	if err != nil {
		return nil, fmt.Errorf("Git can't resolve ref: %q", ref)
	}
	if outp == "" {
		return nil, fmt.Errorf("Git can't resolve ref: %q", ref)
	}

	lines := strings.Split(outp, "\n")
	fullref := &Ref{Sha: lines[0]}

	if len(lines) == 1 {
		// ref is a sha1 and has no symbolic-full-name
		fullref.Name = lines[0] // fullref.Sha
		fullref.Type = RefTypeOther
		return fullref, nil
	}

	// parse the symbolic-full-name
	fullref.Type, fullref.Name = ParseRefToTypeAndName(lines[1])
	return fullref, nil
}
Example #7
0
// List lists all of the git config values
func (c *gitConfig) List() (string, error) {
	return subprocess.SimpleExec("git", "config", "-l")
}
Example #8
0
func (c *gitConfig) UnsetGlobalSection(key string) {
	subprocess.SimpleExec("git", "config", "--global", "--remove-section", key)
}
Example #9
0
// UnsetGlobal removes the git config value for the key from the global config
func (c *gitConfig) UnsetGlobal(key string) {
	subprocess.SimpleExec("git", "config", "--global", "--unset", key)
}
Example #10
0
// SetGlobal sets the git config value for the key in the global config
func (c *gitConfig) SetGlobal(key, val string) {
	subprocess.SimpleExec("git", "config", "--global", key, val)
}
Example #11
0
// SetGlobal sets the git config value for the key in the global config
func (c *gitConfig) SetGlobal(key, val string) (string, error) {
	return subprocess.SimpleExec("git", "config", "--global", key, val)
}
Example #12
0
// UnsetGlobalSection removes the entire named section from the system config
func (c *gitConfig) UnsetSystemSection(key string) (string, error) {
	return subprocess.SimpleExec("git", "config", "--system", "--remove-section", key)
}
Example #13
0
// UnsetSystem removes the git config value for the key from the system config
func (c *gitConfig) UnsetSystem(key string) (string, error) {
	return subprocess.SimpleExec("git", "config", "--system", "--unset", key)
}
Example #14
0
// UnsetGlobal removes the git config value for the key from the global config
func (c *gitConfig) UnsetGlobal(key string) (string, error) {
	return subprocess.SimpleExec("git", "config", "--global", "--unset", key)
}
Example #15
0
// SetSystem sets the git config value for the key in the system config
func (c *gitConfig) SetSystem(key, val string) (string, error) {
	return subprocess.SimpleExec("git", "config", "--system", key, val)
}
Example #16
0
// ListFromFile lists all of the git config values in the given config file
func (c *gitConfig) ListFromFile(f string) (string, error) {
	return subprocess.SimpleExec("git", "config", "-l", "-f", f)
}
Example #17
0
// Version returns the git version
func (c *gitConfig) Version() (string, error) {
	return subprocess.SimpleExec("git", "version")
}
Example #18
0
func UpdateIndex(file string) error {
	_, err := subprocess.SimpleExec("git", "update-index", "-q", "--refresh", file)
	return err
}
Example #19
0
// Find returns the git config value for the key
func (c *gitConfig) FindLocal(val string) string {
	output, _ := subprocess.SimpleExec("git", "config", "--local", val)
	return output
}
Example #20
0
// FindSystem returns the git config value in system scope for the key
func (c *gitConfig) FindSystem(val string) string {
	output, _ := subprocess.SimpleExec("git", "config", "--system", val)
	return output
}