From 4ff649a4eaf5c653176d2fecbfdb6571f0d0d174 Mon Sep 17 00:00:00 2001 From: Kevin Clark Date: Fri, 9 Aug 2013 12:56:37 -0700 Subject: [PATCH] Only count known instructions as build steps stepN is only used in the log line, so if we only produce the log line when there's a message, it should do the right thing. If it's *not* a valid instruction, it gets a line as well, so there's no reason to double up. --- buildfile.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/buildfile.go b/buildfile.go index b969f758ec..a4f89091d1 100644 --- a/buildfile.go +++ b/buildfile.go @@ -488,15 +488,16 @@ func (b *buildFile) Build(context io.Reader) (string, error) { } instruction := strings.ToLower(strings.Trim(tmp[0], " ")) arguments := strings.Trim(tmp[1], " ") - stepN += 1 - // FIXME: only count known instructions as build steps - fmt.Fprintf(b.out, "Step %d : %s %s\n", stepN, strings.ToUpper(instruction), arguments) method, exists := reflect.TypeOf(b).MethodByName("Cmd" + strings.ToUpper(instruction[:1]) + strings.ToLower(instruction[1:])) if !exists { fmt.Fprintf(b.out, "# Skipping unknown instruction %s\n", strings.ToUpper(instruction)) continue } + + stepN += 1 + fmt.Fprintf(b.out, "Step %d : %s %s\n", stepN, strings.ToUpper(instruction), arguments) + ret := method.Func.Call([]reflect.Value{reflect.ValueOf(b), reflect.ValueOf(arguments)})[0].Interface() if ret != nil { return "", ret.(error)