Add --sign and --ack options to refresh
authorCatalin Marinas <catalin.marinas@gmail.com>
Mon, 16 Oct 2006 18:36:49 +0000 (19:36 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Mon, 16 Oct 2006 18:36:49 +0000 (19:36 +0100)
These options automatically sign or acknowledge a patch.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
TODO
stgit/commands/refresh.py
stgit/stack.py

diff --git a/TODO b/TODO
index 6e97fbb..a688f9e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,5 @@
 The TODO list before 1.0:
 
-- automatic patch signing (probably at import time)
 - more regression tests
 - stg help should probably pipe through the $PAGER
 - configurable pull command (currently uses git-pull only)
index 306e7b3..610d18a 100644 (file)
@@ -65,7 +65,13 @@ options = [make_option('-f', '--force',
                        help = 'use COMMNAME as the committer name'),
            make_option('--commemail',
                        help = 'use COMMEMAIL as the committer ' \
-                       'e-mail')]
+                       'e-mail'),
+           make_option('--sign',
+                       help = 'add Signed-off-by line',
+                       action = 'store_true'),
+           make_option('--ack',
+                       help = 'add Acked-by line',
+                       action = 'store_true')]
 
 
 def func(parser, options, args):
@@ -91,11 +97,19 @@ def func(parser, options, args):
     if options.author:
         options.authname, options.authemail = name_email(options.author)
 
+    if options.sign:
+        sign_str = 'Signed-off-by'
+    elif options.ack:
+        sign_str = 'Acked-by'
+    else:
+        sign_str = None
+
     if git.local_changes() \
            or not crt_series.head_top_equal() \
            or options.edit or options.message \
            or options.authname or options.authemail or options.authdate \
-           or options.commname or options.commemail:
+           or options.commname or options.commemail \
+           or options.sign or options.ack:
         print 'Refreshing patch "%s"...' % patch,
         sys.stdout.flush()
 
@@ -110,7 +124,7 @@ def func(parser, options, args):
                                  author_date = options.authdate,
                                  committer_name = options.commname,
                                  committer_email = options.commemail,
-                                 backup = True)
+                                 backup = True, sign_str = sign_str)
 
         print 'done'
     else:
index 0113a1c..26a2fc5 100644 (file)
@@ -601,7 +601,7 @@ class Series:
                       author_name = None, author_email = None,
                       author_date = None,
                       committer_name = None, committer_email = None,
-                      backup = False, log = 'refresh'):
+                      backup = False, sign_str = None, log = 'refresh'):
         """Generates a new commit for the given patch
         """
         name = self.get_current()
@@ -633,6 +633,10 @@ class Series:
         if not committer_email:
             committer_email = patch.get_commemail()
 
+        if sign_str:
+            descr = '%s\n%s: %s <%s>\n' % (descr.rstrip(), sign_str,
+                                           committer_name, committer_email)
+
         bottom = patch.get_bottom()
 
         commit_id = git.commit(files = files,