diff mbox

[U-Boot,v3,03/45] moveconfig: Add an option to commit changes

Message ID 1473743943-15003-4-git-send-email-sjg@chromium.org
State Accepted
Commit 9ede21234172ac9dff078e3e5f6dbd4a407c4680
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass Sept. 13, 2016, 5:18 a.m. UTC
The moveconfig tool is quite clever and generally produces results that
are suitable for sending as a patch without further work. The main required
step is to add the changes to a commit.

Add an option to do this automatically. This allows moveconfig to be used
from a script to convert multiple CONFIG options, once per commit.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2:
- Improve the commit message and add one for resyncing with savedefconfig
- Add some notes on this option to moveconfig.py

 tools/moveconfig.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Tom Rini Sept. 18, 2016, 3:58 p.m. UTC | #1
On Mon, Sep 12, 2016 at 11:18:21PM -0600, Simon Glass wrote:

> The moveconfig tool is quite clever and generally produces results that
> are suitable for sending as a patch without further work. The main required
> step is to add the changes to a commit.
> 
> Add an option to do this automatically. This allows moveconfig to be used
> from a script to convert multiple CONFIG options, once per commit.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 52ec1bd..bc23f93 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -122,6 +122,10 @@  Available options
    Surround each portion of the log with escape sequences to display it
    in color on the terminal.
 
+ -C, --commit
+   Create a git commit with the changes when the operation is complete. A
+   standard commit message is used which may need to be edited.
+
  -d, --defconfigs
   Specify a file containing a list of defconfigs to move
 
@@ -1241,6 +1245,8 @@  def main():
     # Add options here
     parser.add_option('-c', '--color', action='store_true', default=False,
                       help='display the log in color')
+    parser.add_option('-C', '--commit', action='store_true', default=False,
+                      help='Create a git commit for the operation')
     parser.add_option('-d', '--defconfigs', type='string',
                       help='a file containing a list of defconfigs to move')
     parser.add_option('-n', '--dry-run', action='store_true', default=False,
@@ -1286,5 +1292,17 @@  def main():
         cleanup_headers(configs, options)
         cleanup_extra_options(configs, options)
 
+    if options.commit:
+        subprocess.call(['git', 'add', '-u'])
+        if configs:
+            msg = 'Convert %s %sto Kconfig' % (configs[0],
+                    'et al ' if len(configs) > 1 else '')
+            msg += ('\n\nThis converts the following to Kconfig:\n   %s\n' %
+                    '\n   '.join(configs))
+        else:
+            msg = 'configs: Resync with savedefconfig'
+            msg += '\n\nRsync all defconfig files using moveconfig.py'
+        subprocess.call(['git', 'commit', '-s', '-m', msg])
+
 if __name__ == '__main__':
     main()