Don't delete projects with branches

Change-Id: I2c62a131121feafa6cd060672825e377c4dd9ffd
diff --git a/project/operations.go b/project/operations.go
index 9665b00..810c496 100644
--- a/project/operations.go
+++ b/project/operations.go
@@ -208,20 +208,27 @@
 		}
 		extraBranches := false
 		for _, branch := range branches {
-			if !strings.Contains(branch, "HEAD detached") && branch != "master" {
+			if !strings.Contains(branch, "HEAD detached") {
 				extraBranches = true
 				break
 			}
 		}
+
 		if extraBranches || uncommitted || untracked {
 			rmCommand := jirix.Color.Yellow("rm -rf %q", op.source)
 			unManageCommand := jirix.Color.Yellow("rm -rf %q", filepath.Join(op.source, jiri.ProjectMetaDir))
-			msg := fmt.Sprintf("Project %q won't be deleted as it might contain changes", op.project.Name)
+			msg := ""
+			if extraBranches {
+				msg = fmt.Sprintf("Project %q won't be deleted as it contains branches", op.project.Name)
+			} else {
+				msg = fmt.Sprintf("Project %q won't be deleted as it might contain changes", op.project.Name)
+			}
 			msg += fmt.Sprintf("\nIf you no longer need it, invoke '%s'", rmCommand)
 			msg += fmt.Sprintf("\nIf you no longer want jiri to manage it, invoke '%s'\n\n", unManageCommand)
 			jirix.Logger.Warningf(msg)
 			return nil
 		}
+
 		return fmtError(os.RemoveAll(op.source))
 	}
 	rmCommand := jirix.Color.Yellow("rm -rf %q", op.source)
diff --git a/project/project_test.go b/project/project_test.go
index e1fc155..902517c 100644
--- a/project/project_test.go
+++ b/project/project_test.go
@@ -1339,7 +1339,7 @@
 
 // testUpdateUniverseDeletedProject checks that UpdateUniverse will delete a
 // project if gc=true.
-func testUpdateUniverseDeletedProject(t *testing.T, testDirtyProjectDelete bool) {
+func testUpdateUniverseDeletedProject(t *testing.T, testDirtyProjectDelete, testProjectWithBranch bool) {
 	localProjects, fake, cleanup := setupUniverse(t)
 	defer cleanup()
 	if err := fake.UpdateUniverse(false); err != nil {
@@ -1354,6 +1354,12 @@
 	projects := []project.Project{}
 	if testDirtyProjectDelete {
 		writeUncommitedFile(t, fake.X, localProjects[4].Path, "extra", "")
+	} else if testProjectWithBranch {
+		// Create and checkout master.
+		git := gitutil.New(fake.X, gitutil.RootDirOpt(localProjects[4].Path))
+		if err := git.CreateAndCheckoutBranch("master"); err != nil {
+			t.Fatal(err)
+		}
 	}
 	for _, p := range m.Projects {
 		skip := false
@@ -1389,7 +1395,7 @@
 	}
 	for i := 1; i <= 5; i++ {
 		err := dirExists(localProjects[i].Path)
-		if testDirtyProjectDelete && i >= 2 && i <= 4 {
+		if (testProjectWithBranch || testDirtyProjectDelete) && i >= 2 && i <= 4 {
 			if err != nil {
 				t.Fatalf("expected project %q at path %q to exist but it did not", localProjects[i].Name, localProjects[i].Path)
 			}
@@ -1398,9 +1404,11 @@
 		}
 	}
 }
+
 func TestUpdateUniverseDeletedProject(t *testing.T) {
-	testUpdateUniverseDeletedProject(t, false)
-	testUpdateUniverseDeletedProject(t, true)
+	testUpdateUniverseDeletedProject(t, false, false)
+	testUpdateUniverseDeletedProject(t, true, false)
+	testUpdateUniverseDeletedProject(t, false, true)
 }
 
 func TestIgnoredProjectsNotDeleted(t *testing.T) {