diff mbox

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

Message ID 1472516512-26412-4-git-send-email-sjg@chromium.org
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass Aug. 30, 2016, 12:21 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 v2: None

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

Comments

Masahiro Yamada Aug. 30, 2016, 4 a.m. UTC | #1
Hi Simon,

2016-08-30 9:21 GMT+09:00 Simon Glass <sjg@chromium.org>:
> 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>
> ---


Again, you need to describe the option
in the "Available options" section.


> Changes in v2: None
>
>  tools/moveconfig.py | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/tools/moveconfig.py b/tools/moveconfig.py
> index 290270a..cf21318 100755
> --- a/tools/moveconfig.py
> +++ b/tools/moveconfig.py
> @@ -1199,6 +1199,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,
> @@ -1242,5 +1244,13 @@ def main():
>          cleanup_headers(configs, options)
>          cleanup_extra_options(configs, options)
>
> +    if options.commit:
> +        os.system('git add -u')
> +        msg = '''Convert %s to Kconfig
> +
> +Move this option to Kconfig and tidy up existing uses.
> +''' % ', '.join(configs)
> +        os.system('git commit -s -m "%s"' % msg)
> +
>  if __name__ == '__main__':
>      main()

This breaks indentation.
Please re-write the code.


Also, use subprocess, instead of os.system.

http://www.pythonforbeginners.com/os/subprocess-for-system-administrators
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 290270a..cf21318 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -1199,6 +1199,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,
@@ -1242,5 +1244,13 @@  def main():
         cleanup_headers(configs, options)
         cleanup_extra_options(configs, options)
 
+    if options.commit:
+        os.system('git add -u')
+        msg = '''Convert %s to Kconfig
+
+Move this option to Kconfig and tidy up existing uses.
+''' % ', '.join(configs)
+        os.system('git commit -s -m "%s"' % msg)
+
 if __name__ == '__main__':
     main()