Fixes to invirtibuilder for case of missing package in super-repo, missing prod 0.1.26
authorPeter Iannucci <iannucci@mit.edu>
Tue, 16 Jul 2013 21:09:14 +0000 (17:09 -0400)
committerPeter Iannucci <iannucci@mit.edu>
Tue, 16 Jul 2013 21:09:14 +0000 (17:09 -0400)
pocket in super-repo.

debian/changelog
invirtibuilder

index ac05680..5616940 100644 (file)
@@ -1,3 +1,11 @@
+invirt-dev (0.1.26) unstable; urgency=low
+
+  * invirtibuilder creates missing pocket branches in super-repository
+  * invirtibuilder no longer overwrites submodules with .gitmodules blob in
+    tree
+
+ -- Peter Iannucci <iannucci@mit.edu>  Tue, 16 Jul 2013 17:07:00 -0400
+
 invirt-dev (0.1.25) unstable; urgency=low
 
   * invirt-submit-build allows builds in new pockets
index 699ce07..eac57f3 100755 (executable)
@@ -220,10 +220,31 @@ def updateSuperproject(pocket, package, commit, principal, version, env):
     pushes to the superproject.
     """
     superproject = os.path.join(b._REPO_DIR, 'invirt/packages.git')
-    if not b.pocketExists(pocket, superproject):
-        raise Exception("Super-repository does not contain pocket branch '%s'.  Create it first." % pocket)
 
     branch = b.pocketToGit(pocket)
+
+    if not b.pocketExists(pocket, superproject):
+        gitmodules = "\n"
+        gitmodules_hash = logAndRun(['git', 'hash-object', '-w', '--stdin'],
+                                    cwd=superproject,
+                                    stdin_str=gitmodules).strip()
+        tree_items = {'.gitmodules': "100644 blob "+gitmodules_hash}
+        new_tree = "\n".join("%s\t%s" % (v, k) for (k, v) in tree_items.iteritems())
+        new_tree_id = logAndRun(['git', 'mktree', '--missing'],
+                                cwd=superproject,
+                                stdin_str=new_tree).strip()
+        env2 = dict(os.environ)
+        env2['GIT_AUTHOR_NAME'] = config.build.tagger.name
+        env2['GIT_AUTHOR_EMAIL'] = config.build.tagger.email
+        env2['GIT_COMMITTER_NAME'] = config.build.tagger.name
+        env2['GIT_COMMITTER_EMAIL'] = config.build.tagger.email
+        new_commit = logAndRun(['git', 'commit-tree', new_tree_id],
+                               cwd=superproject,
+                               env=env2,
+                               stdin_str="Create new pocket").strip()
+        logAndRun(['git', 'update-ref', 'refs/heads/%s' % branch, new_commit],
+                  cwd=superproject)
+
     tree = logAndRun(['git', 'ls-tree', branch],
                      cwd=superproject).strip()
 
@@ -246,7 +267,7 @@ def updateSuperproject(pocket, package, commit, principal, version, env):
             gitmodules_hash = logAndRun(['git', 'hash-object', '-w', '--stdin'],
                                         cwd=superproject,
                                         stdin_str=gitmodules).strip()
-            tree_items[package] = "100644 blob "+gitmodules_hash
+            tree_items['.gitmodules'] = "100644 blob "+gitmodules_hash
 
     new_tree = "\n".join("%s\t%s" % (v, k) for (k, v) in tree_items.iteritems())
 
@@ -359,6 +380,8 @@ def build():
             env = dict(os.environ)
             env['GIT_COMMITTER_NAME'] = config.build.tagger.name
             env['GIT_COMMITTER_EMAIL'] = config.build.tagger.email
+            env['GIT_AUTHOR_NAME'] = principal.split('@')[0]
+            env['GIT_AUTHOR_EMAIL'] = principal
 
             # If validateBuild returns something other than True, then
             # it means we should copy from that pocket to our pocket.