Add a couple more todos; very minor refactoring.
Change-Id: I9ae2c18cea1ac1b4fb851cc819ac31e65dba1852
diff --git a/review.go b/review.go
index cb4309e..355e20b 100644
--- a/review.go
+++ b/review.go
@@ -8,6 +8,8 @@
// TODO(adg): check style of commit message
// TODO(adg): write doc comment
// TOOD(adg): print gerrit votes on 'pending'
+// TODO(adg): add gofmt commit hook
+// TODO(adg): 'upload' warn about uncommitted changes (maybe commit/create too?)
package main
@@ -262,7 +264,7 @@
var stagedRe = regexp.MustCompile(`^[ACDMR] `)
func hasStagedChanges() bool {
- for _, s := range gitStatus() {
+ for _, s := range runLines("git", "status", "-b", "--porcelain") {
if stagedRe.MatchString(s) {
return true
}
@@ -274,10 +276,6 @@
return strings.TrimSpace(runOutput("git", "rev-parse", "--abbrev-ref", "HEAD"))
}
-func gitStatus() []string {
- return runLines("git", "status", "-b", "--porcelain")
-}
-
func headSubmitted(branch string) bool {
s := "Change-Id: " + headChangeId(branch)
return len(runOutput("git", "log", "--grep", s, "origin/master")) > 0
@@ -337,11 +335,6 @@
}
}
-func dief(format string, args ...interface{}) {
- fmt.Fprintf(os.Stderr, "review: "+format+"\n", args...)
- os.Exit(1)
-}
-
func run(command string, args ...string) {
if err := runErr(command, args...); err != nil {
if !*verbose {
@@ -364,12 +357,6 @@
return cmd.Run()
}
-func verbosef(format string, args ...interface{}) {
- if *verbose {
- fmt.Fprintf(os.Stderr, format, args...)
- }
-}
-
func runOutput(command string, args ...string) string {
b, err := exec.Command(command, args...).CombinedOutput()
if err != nil {
@@ -393,3 +380,14 @@
func commandString(command string, args []string) string {
return strings.Join(append([]string{command}, args...), " ")
}
+
+func dief(format string, args ...interface{}) {
+ fmt.Fprintf(os.Stderr, "review: "+format+"\n", args...)
+ os.Exit(1)
+}
+
+func verbosef(format string, args ...interface{}) {
+ if *verbose {
+ fmt.Fprintf(os.Stderr, format, args...)
+ }
+}