Update master of plcapi.
[build.git] / module-tools.py
index 68d5458..20e78d5 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python -u
 
-import sys, os
+import sys, os, os.path
 import re
 import time
 import tempfile
@@ -272,7 +272,7 @@ class GitRepository:
     def gitweb(self):
         c = Command("git show | grep commit | awk '{print $2;}'", self.options)
         out = self.__run_in_repo(c.output_of).strip()
-        return "http://git.onelab.eu/?p=%s.git;a=commit;h=%s" % (self.pathname(), out)
+        return "http://git.onelab.eu/?p=%s.git;a=commit;h=%s" % (self.name(), out)
 
     def repo_root(self):
         c = Command("git remote show origin", self.options)
@@ -1265,11 +1265,20 @@ def modules_diff(first, second):
 
 def release_changelog(options, buildtag_old, buildtag_new):
 
-    tagfile = options.distrotags[0]
-    if not tagfile:
+    try:
+        tagfile = options.distrotags[0]
+        if not tagfile: raise 
+    except:
         print "ERROR: provide a tagfile name (eg. onelab, onelab-k27, planetlab)"
         return
-    tagfile = "%s-tags.mk" % tagfile
+    # mmh, sounds wrong to blindly add the extension 
+    # if in a build directory, guess from existing files
+    if os.path.isfile (tagfile): 
+        pass
+    elif os.path.isfile ("%s-tags.mk" % tagfile):
+        tagfile="%s-tags.mk" % tagfile
+    else:
+        tagfile = "%s-tags.mk" % tagfile
     
     print '----'
     print '----'
@@ -1326,7 +1335,7 @@ def release_changelog(options, buildtag_old, buildtag_new):
             print ' * to', second, m.repository.gitweb()
 
         print '{{{'
-        os.system("diff -u %s %s" % (tmpfile, specfile))
+        os.system("diff -u %s %s | sed -e 's,%s,[[previous version]],'" % (tmpfile, specfile,tmpfile))
         print '}}}'
 
         os.unlink(tmpfile)
@@ -1570,7 +1579,11 @@ Branches:
                     module.html_dump_body()
                 Module.html_dump_footer()
         else:
-            release_changelog(options, *args)
+            # if we provide, say a b c d, we want to build (a,b) (b,c) and (c,d)
+            # remember that the changelog in the twiki comes latest first, so
+            # we typically have here latest latest-1 latest-2
+            for (tag_to,tag_from) in zip ( args[:-1], args [1:]):
+                release_changelog(options, tag_from,tag_to)
             
     
 ####################