summaryrefslogtreecommitdiff
path: root/classes/base.bbclass
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@openmoko.org>2008-09-06 03:00:30 +0200
committerHolger Freyther <ich@tamarin.(none)>2008-10-15 18:59:32 +0200
commit55e0ea8b49448d2277e54e27ebb61f0861e3fcc8 (patch)
treead4f95597621e3a7afffb6df0c4f5704f288a190 /classes/base.bbclass
parentf4a36e1e110ced78c3b360e10d78ef236d850597 (diff)
[base] Autodetect the SCM and add listing of git repositories
Diffstat (limited to 'classes/base.bbclass')
-rw-r--r--classes/base.bbclass44
1 files changed, 42 insertions, 2 deletions
diff --git a/classes/base.bbclass b/classes/base.bbclass
index bac46f138d..8ff2346a34 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -739,8 +739,48 @@ def base_get_metadata_svn_revision(d):
pass
return revision
-METADATA_BRANCH ?= "${@base_get_metadata_monotone_branch(d)}"
-METADATA_REVISION ?= "${@base_get_metadata_monotone_revision(d)}"
+def base_get_metadata_git_branch(d):
+ import os
+ branch = os.popen('cd %s; git-branch | grep "^* " | tr -d "* "' % base_get_scmbasepath(d)).read()
+
+ if len(branch) != 0:
+ return branch
+ return "<unknown>"
+
+def base_get_metadata_git_revision(d):
+ import os
+ rev = os.popen("cd %s; git-log -n 1 --pretty=oneline --" % base_get_scmbasepath(d)).read().split(" ")[0]
+ if len(rev) != 0:
+ return rev
+ return "<unknown>"
+
+def base_detect_revision(d):
+ scms = [base_get_metadata_monotone_revision, \
+ base_get_metadata_svn_revision, \
+ base_get_metadata_git_revision]
+
+ for scm in scms:
+ rev = scm(d)
+ if rev <> "<unknown>":
+ return rev
+
+ return "<unknown>"
+
+def base_detect_branch(d):
+ scms = [base_get_metadata_monotone_branch, \
+ base_get_metadata_git_branch]
+
+ for scm in scms:
+ rev = scm(d)
+ if rev <> "<unknown>":
+ return rev
+
+ return "<unknown>"
+
+
+
+METADATA_BRANCH ?= "${@base_detect_branch(d)}"
+METADATA_REVISION ?= "${@base_detect_revision(d)}"
addhandler base_eventhandler
python base_eventhandler() {