Path string
}
-func GitOpen(gpath string) (r Repo, err error) {
+func normalizePath(gpath string) string {
if !path.IsAbs(gpath) {
cwd, err := os.Getwd()
if err != nil {
- fmt.Printf("Getwd failed?\n")
- return r, err
+ panic("Getwd failed?\n")
}
gpath = cwd + "/" + gpath
gpath = path.Clean(gpath)
}
+ return gpath
+}
+
+func GitOpen(gpath string) (r Repo, err error) {
+ gpath = normalizePath(gpath)
fmt.Printf("Path: %s\n", gpath)
r.Path = gpath
return
}
+func globToFullPath(glob string) (files []string, err error) {
+ files, err = filepath.Glob(glob)
+ if err != nil {
+ return
+ }
+ for i := range files {
+ files[i] = normalizePath(files[i])
+ }
+ return
+}
+
func (r Repo) Am(amglob string) (out []byte, err error) {
- files, err := filepath.Glob(amglob)
+ files, err := globToFullPath(amglob)
if err != nil {
return
}
err = fmt.Errorf("%s didn't match any files", amglob)
return
}
+
out, err = r.gitCmd(append([]string{"am", "--reject"}, files...)...)
return
// Do a 'git am', and if it fails, clean up the tree
func (r Repo) AmClean(amglob string) (out []byte, err error) {
- files, err := filepath.Glob(amglob)
+ files, err := globToFullPath(amglob)
if err != nil {
return
}