waf: git_submodule: add function git_submodule_head_hash

This commit is contained in:
Gustavo Jose de Sousa 2016-02-15 19:36:45 +00:00 committed by Lucas De Marchi
parent 33fce2bfe5
commit d57851e2a9
1 changed files with 7 additions and 0 deletions

View File

@ -102,3 +102,10 @@ def git_submodule(bld, git_submodule, **kw):
kw['features'].append('git_submodule')
return bld(**kw)
@conf
def git_submodule_head_hash(self, name):
module_node = self.srcnode.make_node(os.path.join('modules', name))
cmd = self.env.get_flat('GIT'), '-C', module_node.abspath(), 'rev-parse', 'HEAD'
out = self.cmd_and_log(cmd, quiet=Context.BOTH)
return out.strip()