From 3078a3ee684736b7d0c6d9f3199985144aa6d534 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Wed, 8 Mar 2017 18:32:32 -0300 Subject: [PATCH] Change "@" for "$" as dynamic var identifier --- README.md | 12 +++++++++++- variable_handling.go | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca733f16..a7d07281 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,17 @@ Result: 'abc' #### Dynamic variables -If you prefix a variable with `@`, then the variable is considered a dynamic variable. The value after the @-synbol will be treated as a command and the output assigned. +If you prefix a variable with `$`, then the variable is considered a dynamic +variable. The value after the $-symbol will be treated as a command and the +output assigned. + +```yml +build: + cmds: + - go build -ldflags="-X main.Version={{.LAST_GIT_COMMIT}}" main.go + vars: + LAST_GIT_COMMIT: $git log -n 1 --format=%h +``` ### Go's template engine diff --git a/variable_handling.go b/variable_handling.go index b5609dd3..30b38014 100644 --- a/variable_handling.go +++ b/variable_handling.go @@ -23,7 +23,7 @@ func handleDynamicVariableContent(value string) (string, error) { if value == "" { return value, nil } - if value[0] != '@' { + if value[0] != '$' { return value, nil } var cmd *exec.Cmd