diff --git a/tools/default.defs b/tools/default.defs index 8dac3e58a3..14bc9cef60 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -18,6 +18,7 @@ include_defs('//lib/auto/auto_value.defs') include_defs('//tools/gwt-constants.defs') include_defs('//tools/java_doc.defs') include_defs('//tools/java_sources.defs') +include_defs('//tools/git.defs') import copy # Set defaults on java rules: @@ -130,7 +131,7 @@ def gerrit_plugin( type = 'plugin', visibility = ['PUBLIC']): from multiprocessing import cpu_count - mf_cmd = 'v=\$(git describe HEAD);' + mf_cmd = 'v=%s;' % git_describe(name) if manifest_file: mf_src = [manifest_file] mf_cmd += 'sed "s:@VERSION@:$v:g" $SRCS >$OUT' diff --git a/tools/git.defs b/tools/git.defs index c58ac884db..ca083ad96f 100644 --- a/tools/git.defs +++ b/tools/git.defs @@ -12,10 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -def git_describe(): +def git_describe(plugin = None): import subprocess cmd = ['git', 'describe', '--match', 'v[0-9].*', '--dirty'] - p = subprocess.Popen(cmd, stdout = subprocess.PIPE) + if not plugin: + p = subprocess.Popen(cmd, stdout = subprocess.PIPE) + else: + p = subprocess.Popen(cmd, stdout = subprocess.PIPE, cwd = 'plugins/%s' % plugin) v = p.communicate()[0].strip() r = p.returncode if r != 0: