diff --git a/bugapp/Commit.go b/bugapp/Commit.go index 202b036..2d8944d 100644 --- a/bugapp/Commit.go +++ b/bugapp/Commit.go @@ -9,10 +9,11 @@ import ( func Commit(args ArgumentList) { options := make(map[string]bool) if !args.HasArgument("--no-autoclose") { - options["autoclose"] = false - } else { options["autoclose"] = true + } else { + options["autoclose"] = false } + scm, _, err := scm.DetectSCM(options) if err != nil { fmt.Printf("Error: %s\n", err.Error()) diff --git a/bugapp/Version.go b/bugapp/Version.go index 33dbac4..c40dd30 100644 --- a/bugapp/Version.go +++ b/bugapp/Version.go @@ -6,6 +6,6 @@ import ( ) func Version() { - fmt.Printf("%s version 0.3-dev\n", os.Args[0]) + fmt.Printf("%s version 0.3.1\n", os.Args[0]) } diff --git a/scm/GitManager.go b/scm/GitManager.go index 5d347ca..4710c38 100644 --- a/scm/GitManager.go +++ b/scm/GitManager.go @@ -56,7 +56,7 @@ func (a GitManager) getDeletedIdentifiers(dir bugs.Directory) []string { continue } if file[0:1] == "D" && strings.HasSuffix(file, "Identifier") { - ghRegex := regexp.MustCompile("-Github:(\\s*)(.*)") + ghRegex := regexp.MustCompile("(?im)^-Github:(\\s*)(.*)(\\s*)$^") diff := exec.Command("git", "diff", "--staged", "--", file[3:]) diffout, _ := diff.CombinedOutput() if matches := ghRegex.FindStringSubmatch(string(diffout)); len(matches) > 2 { diff --git a/scm/GitManager_test.go b/scm/GitManager_test.go index a970910..8559c8e 100644 --- a/scm/GitManager_test.go +++ b/scm/GitManager_test.go @@ -107,11 +107,8 @@ func (m GitTester) GetManager() SCMHandler { } func TestGitBugRenameCommits(t *testing.T) { - if os.Getenv("TRAVIS") == "true" { - // I think this is related to the version of git installed - // on Travis, but the apt add-on won't let us install a newer - // version to test. For now, this test gets skipped. - t.Skip("Test failing under Travis for unknown reasons.") + if os.Getenv("TRAVIS") == "true" && os.Getenv("TRAVIS_OS_NAME") == "linux" { + t.Skip("Skipping test which fails only under Travis for unknown reasons..") return } gm := GitTester{} @@ -139,3 +136,11 @@ func TestGitFilesOutsideOfBugNotCommited(t *testing.T) { gm.handler = GitManager{} runtestCommitDirtyTree(&gm, t) } + +func TestGitManagerGetType(t *testing.T) { + manager := GitManager{} + + if getType := manager.GetSCMType(); getType != "git" { + t.Error("Incorrect SCM Type for GitManager. Got " + getType) + } +} diff --git a/scm/TestHelpers_test.go b/scm/TestHelpers_test.go index 45febf2..d3eead5 100644 --- a/scm/TestHelpers_test.go +++ b/scm/TestHelpers_test.go @@ -1,6 +1,7 @@ package scm import ( + "fmt" "github.com/driusan/bug/bugs" "io/ioutil" "os" @@ -58,6 +59,7 @@ func assertLogs(tester ManagerTester, t *testing.T, titles []string, diffs []str } else { if diff != diffs[i] { t.Error("Incorrect diff for " + titles[i]) + fmt.Fprintf(os.Stderr, "Got %s, expected %s", diff, diffs[i]) } } } @@ -68,7 +70,6 @@ func runtestRenameCommitsHelper(tester ManagerTester, t *testing.T, expectedDiff defer tester.TearDown() if err != nil { t.Error("Could not initialize repo") - panic("Something went wrong trying to initialize git:" + err.Error()) return } @@ -77,10 +78,10 @@ func runtestRenameCommitsHelper(tester ManagerTester, t *testing.T, expectedDiff t.Error("Could not get manager") return } - os.Mkdir("issues", 0755) - runCmd("bug", "create", "-n", "Test bug") + os.MkdirAll("issues/Test-bug", 0755) + ioutil.WriteFile("issues/Test-bug/Description", []byte(""), 0644) m.Commit(bugs.Directory(tester.GetWorkDir()), "Initial commit") - runCmd("bug", "relabel", "1", "Renamed bug") + runCmd("bug", "relabel", "1", "Renamed", "bug") m.Commit(bugs.Directory(tester.GetWorkDir()), "This is a test rename") tester.AssertCleanTree(t) @@ -100,7 +101,7 @@ func runtestCommitDirtyTree(tester ManagerTester, t *testing.T) { return } os.Mkdir("issues", 0755) - runCmd("bug", "create", "-n", "Test bug") + runCmd("bug", "create", "-n", "Test", "bug") if err = ioutil.WriteFile("donotcommit.txt", []byte(""), 0644); err != nil { t.Error("Could not write file") return