github.com/grantbow/fit@v0.7.1-0.20220916164603-1f7c88ac81e6/scm/HgManager.go (about) 1 package scm 2 3 import ( 4 "fmt" 5 bugs "github.com/grantbow/fit/issues" 6 "os/exec" 7 ) 8 9 // HgManager is a struct for a mercurial (hg) software configuration manager. 10 type HgManager struct{} 11 12 // Purge would give the hg command to purge files but this is not supported. 13 func (mgr HgManager) Purge(dir bugs.Directory) error { 14 return UnsupportedType("Purge is not supported under Hg. Sorry!") 15 } 16 17 // Commit gives the hg command to commit files. 18 func (mgr HgManager) Commit(dir bugs.Directory, commitMsg string, config bugs.Config) error { 19 cmd := exec.Command("hg", "addremove", string(dir)) 20 if err := cmd.Run(); err != nil { 21 fmt.Printf("Could not add issues to be committed: %s?\n", err.Error()) 22 return err 23 } 24 25 cmd = exec.Command("hg", "commit", string(dir), "-m", commitMsg) 26 // stdout and stderr not captured in HgManager_test.go runtestCommitDirtyTree() 27 if err := cmd.Run(); err != nil { 28 //fmt.Printf("post 2 runtestCommitDirtyTree error %v\n", err) // 255 when $?=1 and stdout text "nothing changed" present 29 //fmt.Printf("No new issues to commit.\n") // assumed this error incorrectly, same for GitManager 30 fmt.Printf("Commit error %v\n", err.Error()) // $? 31 return err 32 } 33 return nil 34 } 35 36 // SCMTyper returns hg. 37 func (mgr HgManager) SCMTyper() string { 38 return "hg" 39 } 40 41 // SCMIssuesUpdaters returns in error 42 func (mgr HgManager) SCMIssuesUpdaters(config bugs.Config) ([]byte, error) { 43 return []byte(""), nil 44 } 45 46 // SCMIssuesCacher returns in error 47 func (mgr HgManager) SCMIssuesCacher(config bugs.Config) ([]byte, error) { 48 return []byte(""), nil 49 }