Example #1
0
File: git.go Project: kiyor/ezgit
func (git *Git) PullFile(branch string, file string) error {
	cmd := fmt.Sprintf("%s fetch", git.prefix)
	_, err := golib.Osexec(cmd)
	if err != nil {
		return err
	}
	cmd = fmt.Sprintf("%s checkout %s -- %s", git.prefix, branch, file)
	_, err = golib.Osexec(cmd)
	return err
}
Example #2
0
File: git.go Project: kiyor/ezgit
// func (git *Git) Add(files []string) error {
// 	var fs string
// 	for _, v := range files {
// 		fs += v + " "
// 	}
// 	cmd := fmt.Sprintf("%s add %s", git.prefix, fs)
// 	_, err := golib.Osexec(cmd)
// 	return err
// }
func (git *Git) Add(file interface{}) error {
	r := strings.NewReplacer("[", "", "]", "", ",", "")
	fs := r.Replace(fmt.Sprintf("%v", file))
	cmd := fmt.Sprintf("%s add %s", git.prefix, fs)
	_, err := golib.Osexec(cmd)
	return err
}
Example #3
0
File: git.go Project: kiyor/ezgit
func (git *Git) Commit(comment string, file interface{}) error {
	r := strings.NewReplacer("[", "", "]", "", ",", "")
	fs := r.Replace(fmt.Sprintf("%v", file))
	cmd := fmt.Sprintf("%s commit -m '%s' %s", git.prefix, comment, fs)
	_, err := golib.Osexec(cmd)
	return err
}
Example #4
0
File: git.go Project: kiyor/ezgit
func (git *Git) Clone(remote string) error {
	part := strings.Split(git.Path, "/")
	var path string
	for _, v := range part[:len(part)-1] {
		if v != "" {
			path += "/" + v
		}
	}
	cmd := fmt.Sprintf("mkdir -p %s && cd %s && %s clone %s", path, path, git.bin, remote)
	_, err := golib.Osexec(cmd)
	return err
}
Example #5
0
File: git.go Project: kiyor/ezgit
func (git *Git) PushTo(remote string) error {
	cmd := fmt.Sprintf("%s push %s", git.prefix, remote)
	_, err := golib.Osexec(cmd)
	return err
}
Example #6
0
File: git.go Project: kiyor/ezgit
//normally output is not error, it's just std err output
func (git *Git) Push() error {
	cmd := fmt.Sprintf("%s push", git.prefix)
	_, err := golib.Osexec(cmd)
	return err
}
Example #7
0
File: git.go Project: kiyor/ezgit
func (git *Git) CommitAll(comment string) error {
	cmd := fmt.Sprintf("%s commit -a -m '%s'", git.prefix, comment)
	_, err := golib.Osexec(cmd)
	return err
}
Example #8
0
File: git.go Project: kiyor/ezgit
func (git *Git) AddRemote(name string, location string) error {
	cmd := fmt.Sprintf("%s remote add %s %s", git.prefix, name, location)
	_, err := golib.Osexec(cmd)
	return err
}
Example #9
0
File: git.go Project: kiyor/ezgit
func (git *Git) Init() error {
	cmd := fmt.Sprintf("%s init", git.prefix)
	_, err := golib.Osexec(cmd)
	return err
}