Patchwork [6/7] scripts/combo-layer: auto-commit updated config file

login
register
mail settings
Submitter Paul Eggleton
Date Nov. 4, 2011, 5:55 p.m.
Message ID <161f7b1dc39efa2a2f4041d223b0e52ee3fdf23c.1320429268.git.paul.eggleton@linux.intel.com>
Download mbox | patch
Permalink /patch/14299/
State Accepted
Headers show

Comments

Paul Eggleton - Nov. 4, 2011, 5:55 p.m.
If the config file is tracked within the combo-layer repository and it
is updated at the end of the "update" operation (because last_revision
has been changed), then automatically commit the file. This ensures that
multiple people can perform updates on different machines without the
last revision information going missing.

(If the file is outside the repository or is masked via .gitignore, this
will do nothing.)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 scripts/combo-layer |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

Patch

diff --git a/scripts/combo-layer b/scripts/combo-layer
index f3480dc..64ea9a9 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -230,6 +230,18 @@  def action_update(conf, args):
     action_apply_patch(conf, args)
     runcmd("rm -rf %s" % patch_dir)
 
+    # Step 7: commit the updated config file if it's being tracked
+    relpath = os.path.relpath(conf.conffile)
+    try:
+        output = runcmd("git status --porcelain %s" % relpath)
+    except:
+        # Outside the repository
+        output = None
+    if output:
+        logger.info("Committing updated configuration file")
+        if output.lstrip().startswith("M"):
+            runcmd('git commit --author="combo-layer <combo-layer@localhost>" -m "Automatic commit to update last_revision" %s' % relpath)
+
 def action_apply_patch(conf, args):
     """
         apply the generated patch list to combo repo