export: update 'VCS:' tag in spec
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 3 Dec 2012 10:44:43 +0000 (12:44 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 3 Dec 2012 11:04:57 +0000 (13:04 +0200)
Updates/inserts a 'VCS:' tag to the spec file, after exporting the
sources. The format of the tag is 'repopath#tagname'.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gitbuildsys/cmd_export.py

index 71d878a33ee3abcad72f9527a7844a8732f91afa..d9a75a40311b1333b9f3fb84835fe5805547cedc 100644 (file)
@@ -23,6 +23,7 @@ import os
 import re
 import shutil
 import errno
+from urlparse import urlparse
 
 from gitbuildsys import msger, utils, errors
 from gitbuildsys.conf import configmgr
@@ -120,6 +121,20 @@ def create_gbp_export_args(repo, commit, export_dir, tmp_dir, spec, args,
     else:
         squash_patches_until = configmgr.get('squash_patches_until', 'general')
 
+    # Determine the remote repourl
+    reponame = ""
+    remotes = repo.get_remote_repos()
+    if remotes:
+        remotename = 'origin' if 'origin' in remotes else remotes.keys()[0]
+        # Take the remote repo of current branch, if available
+        try:
+            upstream_branch = repo.get_upstream_branch(repo.branch)
+            if upstream_branch:
+                remotename = upstream_branch.split("/")[0]
+        except GitRepositoryError:
+            pass
+        reponame = urlparse(remotes[remotename][0]).path[1:]
+
     packaging_dir = get_packaging_dir(args)
     # Now, start constructing the argument list
     argv = ["argv[0] placeholder",
@@ -132,7 +147,8 @@ def create_gbp_export_args(repo, commit, export_dir, tmp_dir, spec, args,
             "--git-spec-file=%s" % spec,
             "--git-export=%s" % commit,
             "--git-upstream-branch=%s" % upstream_branch,
-            "--git-upstream-tag=%s" % upstream_tag]
+            "--git-upstream-tag=%s" % upstream_tag,
+            "--git-spec-vcs-tag=%s#%%(tagname)s" % reponame]
 
     if force_native or is_native_pkg(repo, args):
         argv.extend(["--git-no-patch-export",