diff options
| -rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 45bdec0553..2e5388221f 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
| @@ -398,6 +398,31 @@ class Git(FetchMethod): | |||
| 398 | def _build_revision(self, ud, d, name): | 398 | def _build_revision(self, ud, d, name): |
| 399 | return ud.revisions[name] | 399 | return ud.revisions[name] |
| 400 | 400 | ||
| 401 | def gitpkgv_revision(self, ud, d, name): | ||
| 402 | """ | ||
| 403 | Return a sortable revision number by counting commits in the history | ||
| 404 | Based on gitpkgv.bblass in meta-openembedded | ||
| 405 | """ | ||
| 406 | rev = self._build_revision(ud, d, name) | ||
| 407 | localpath = ud.localpath | ||
| 408 | rev_file = os.path.join(localpath, "oe-gitpkgv_" + rev) | ||
| 409 | if not os.path.exists(localpath): | ||
| 410 | commits = None | ||
| 411 | else: | ||
| 412 | if not os.path.exists(rev_file) or not os.path.getsize(rev_file): | ||
| 413 | from pipes import quote | ||
| 414 | commits = bb.fetch2.runfetchcmd( | ||
| 415 | "git rev-list %s -- | wc -l" % (quote(rev)), | ||
| 416 | d, quiet=True).strip().lstrip('0') | ||
| 417 | if commits: | ||
| 418 | open(rev_file, "w").write("%d\n" % int(commits)) | ||
| 419 | else: | ||
| 420 | commits = open(rev_file, "r").readline(128).strip() | ||
| 421 | if commits: | ||
| 422 | return False, "%s+%s" % (commits, rev[:7]) | ||
| 423 | else: | ||
| 424 | return True, str(rev) | ||
| 425 | |||
| 401 | def checkstatus(self, ud, d): | 426 | def checkstatus(self, ud, d): |
| 402 | try: | 427 | try: |
| 403 | self._lsremote(ud, d, "") | 428 | self._lsremote(ud, d, "") |
