For plugins, run 'git describe' from their BUCK directory
Thereby, we allow plugins to provide more than just one plugin (e.g.: as javamelody does), and we get correct 'git describe' output when cloning plugins under different names or more than once. Change-Id: I7afe621265b3424ef78271e3bbeeca22b2cf4cf8
This commit is contained in:
parent
33a904468d
commit
eb8da51256
@ -20,6 +20,8 @@ include_defs('//tools/java_doc.defs')
|
||||
include_defs('//tools/java_sources.defs')
|
||||
include_defs('//tools/git.defs')
|
||||
import copy
|
||||
import traceback
|
||||
import os
|
||||
|
||||
# Set defaults on java rules:
|
||||
# - Add AutoValue annotation processing support.
|
||||
@ -131,7 +133,10 @@ def gerrit_plugin(
|
||||
type = 'plugin',
|
||||
visibility = ['PUBLIC']):
|
||||
from multiprocessing import cpu_count
|
||||
mf_cmd = 'v=%s;' % git_describe(name)
|
||||
tb = traceback.extract_stack()
|
||||
calling_BUCK_file = tb[-2][0]
|
||||
calling_BUCK_dir = os.path.abspath(os.path.dirname(calling_BUCK_file))
|
||||
mf_cmd = 'v=%s;' % git_describe(calling_BUCK_dir)
|
||||
if manifest_file:
|
||||
mf_src = [manifest_file]
|
||||
mf_cmd += 'sed "s:@VERSION@:$v:g" $SRCS >$OUT'
|
||||
|
@ -12,13 +12,13 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
def git_describe(plugin = None):
|
||||
def git_describe(directory = None):
|
||||
import subprocess
|
||||
cmd = ['git', 'describe', '--always', '--match', 'v[0-9].*', '--dirty']
|
||||
if not plugin or plugin == '${pluginName}':
|
||||
if not directory:
|
||||
p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
|
||||
else:
|
||||
p = subprocess.Popen(cmd, stdout = subprocess.PIPE, cwd = 'plugins/%s' % plugin)
|
||||
p = subprocess.Popen(cmd, stdout = subprocess.PIPE, cwd = directory)
|
||||
v = p.communicate()[0].strip()
|
||||
r = p.returncode
|
||||
if r != 0:
|
||||
|
Loading…
Reference in New Issue
Block a user