public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/commit-mklog-add-co)] commit-mklog: Add --co argument.
@ 2021-08-17 13:33 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2021-08-17 13:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:68797b65eedabeb0712588409933cb69809c5fbc

commit 68797b65eedabeb0712588409933cb69809c5fbc
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Aug 17 14:57:40 2021 +0200

    commit-mklog: Add --co argument.
    
    The argument can be used for addition of Co-Authored-By lines
    with --trailer='Co-Authored-By=Mona Lisa Octocat <mona@github.com>'.
    
    contrib/ChangeLog:
    
            * gcc-git-customization.sh: Wrap $@ in quotes.
            * git-commit-mklog.py: Add new argument --co.
            * mklog.py: Skip the Co-Authored-By lines.

Diff:
---
 contrib/gcc-git-customization.sh | 2 +-
 contrib/git-commit-mklog.py      | 6 ++++++
 contrib/mklog.py                 | 9 ++++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh
index 6f8f23deebf..aca61b781ff 100755
--- a/contrib/gcc-git-customization.sh
+++ b/contrib/gcc-git-customization.sh
@@ -28,7 +28,7 @@ git config alias.gcc-undescr \!"f() { o=\$(git config --get gcc-config.upstream)
 git config alias.gcc-verify '!f() { "`git rev-parse --show-toplevel`/contrib/gcc-changelog/git_check_commit.py" $@; } ; f'
 git config alias.gcc-backport '!f() { "`git rev-parse --show-toplevel`/contrib/git-backport.py" $@; } ; f'
 git config alias.gcc-mklog '!f() { "`git rev-parse --show-toplevel`/contrib/mklog.py" $@; } ; f'
-git config alias.gcc-commit-mklog '!f() { "`git rev-parse --show-toplevel`/contrib/git-commit-mklog.py" $@; }; f'
+git config alias.gcc-commit-mklog '!f() { "`git rev-parse --show-toplevel`/contrib/git-commit-mklog.py" "$@"; }; f'
 
 # Make diff on MD files use "(define" as a function marker.
 # Use this in conjunction with a .gitattributes file containing
diff --git a/contrib/git-commit-mklog.py b/contrib/git-commit-mklog.py
index 9c59fb97809..eda3fc4a892 100755
--- a/contrib/git-commit-mklog.py
+++ b/contrib/git-commit-mklog.py
@@ -37,6 +37,8 @@ if __name__ == '__main__':
                         help='Add the specified PRs (comma separated)')
     parser.add_argument('-p', '--fill-up-bug-titles', action='store_true',
                         help='Download title of mentioned PRs')
+    parser.add_argument('--co',
+                        help='Add Co-Authored-By trailer (comma separated)')
     args, unknown_args = parser.parse_known_args()
 
     myenv['GCC_FORCE_MKLOG'] = '1'
@@ -49,5 +51,9 @@ if __name__ == '__main__':
     if mklog_args:
         myenv['GCC_MKLOG_ARGS'] = ' '.join(mklog_args)
 
+    if args.co:
+        for author in args.co.split(','):
+            unknown_args.append(f'--trailer "Co-Authored-By: {author}"')
+
     commit_args = ' '.join(unknown_args)
     subprocess.run(f'git commit {commit_args}', shell=True, env=myenv)
diff --git a/contrib/mklog.py b/contrib/mklog.py
index d2aea85c7cc..d362be5ab10 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -40,6 +40,7 @@ from unidiff import PatchSet
 
 LINE_LIMIT = 100
 TAB_WIDTH = 8
+CO_AUTHORED_BY_PREFIX = 'co-authored-by: '
 
 pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)')
 prnum_regex = re.compile(r'PR (?P<comp>[a-z+-]+)/(?P<num>[0-9]+)')
@@ -317,6 +318,12 @@ def update_copyright(data):
                 f.write(content)
 
 
+def skip_line_in_changelog(line):
+    if line.lower().startswith(CO_AUTHORED_BY_PREFIX) or line.startswith('#'):
+        return False
+    return True
+
+
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description=help_message)
     parser.add_argument('input', nargs='?',
@@ -350,7 +357,7 @@ if __name__ == '__main__':
                                     args.fill_up_bug_titles, args.pr_numbers)
         if args.changelog:
             lines = open(args.changelog).read().split('\n')
-            start = list(takewhile(lambda l: not l.startswith('#'), lines))
+            start = list(takewhile(skip_line_in_changelog, lines))
             end = lines[len(start):]
             with open(args.changelog, 'w') as f:
                 if not start or not start[0]:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/marxin/heads/commit-mklog-add-co)] commit-mklog: Add --co argument.
@ 2021-08-17 13:10 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2021-08-17 13:10 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:340296a689b254940a710f9a8f52bf6bb017b34c

commit 340296a689b254940a710f9a8f52bf6bb017b34c
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Aug 17 14:57:40 2021 +0200

    commit-mklog: Add --co argument.
    
    The argument can be used for addition of Co-Authored-By lines
    with --trailer='Co-Authored-By=Mona Lisa Octocat <mona@github.com>'.
    
    contrib/ChangeLog:
    
            * gcc-git-customization.sh: Wrap $@ in quotes.
            * git-commit-mklog.py: Add new argument --co.
            * mklog.py: Skip the Co-Authored-By lines.

Diff:
---
 contrib/gcc-git-customization.sh | 2 +-
 contrib/git-commit-mklog.py      | 6 ++++++
 contrib/mklog.py                 | 8 +++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh
index 6f8f23deebf..aca61b781ff 100755
--- a/contrib/gcc-git-customization.sh
+++ b/contrib/gcc-git-customization.sh
@@ -28,7 +28,7 @@ git config alias.gcc-undescr \!"f() { o=\$(git config --get gcc-config.upstream)
 git config alias.gcc-verify '!f() { "`git rev-parse --show-toplevel`/contrib/gcc-changelog/git_check_commit.py" $@; } ; f'
 git config alias.gcc-backport '!f() { "`git rev-parse --show-toplevel`/contrib/git-backport.py" $@; } ; f'
 git config alias.gcc-mklog '!f() { "`git rev-parse --show-toplevel`/contrib/mklog.py" $@; } ; f'
-git config alias.gcc-commit-mklog '!f() { "`git rev-parse --show-toplevel`/contrib/git-commit-mklog.py" $@; }; f'
+git config alias.gcc-commit-mklog '!f() { "`git rev-parse --show-toplevel`/contrib/git-commit-mklog.py" "$@"; }; f'
 
 # Make diff on MD files use "(define" as a function marker.
 # Use this in conjunction with a .gitattributes file containing
diff --git a/contrib/git-commit-mklog.py b/contrib/git-commit-mklog.py
index 9c59fb97809..eda3fc4a892 100755
--- a/contrib/git-commit-mklog.py
+++ b/contrib/git-commit-mklog.py
@@ -37,6 +37,8 @@ if __name__ == '__main__':
                         help='Add the specified PRs (comma separated)')
     parser.add_argument('-p', '--fill-up-bug-titles', action='store_true',
                         help='Download title of mentioned PRs')
+    parser.add_argument('--co',
+                        help='Add Co-Authored-By trailer (comma separated)')
     args, unknown_args = parser.parse_known_args()
 
     myenv['GCC_FORCE_MKLOG'] = '1'
@@ -49,5 +51,9 @@ if __name__ == '__main__':
     if mklog_args:
         myenv['GCC_MKLOG_ARGS'] = ' '.join(mklog_args)
 
+    if args.co:
+        for author in args.co.split(','):
+            unknown_args.append(f'--trailer "Co-Authored-By: {author}"')
+
     commit_args = ' '.join(unknown_args)
     subprocess.run(f'git commit {commit_args}', shell=True, env=myenv)
diff --git a/contrib/mklog.py b/contrib/mklog.py
index d2aea85c7cc..8430f65a879 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -317,6 +317,12 @@ def update_copyright(data):
                 f.write(content)
 
 
+def skip_line_in_changelog(line):
+    if line.startswith('Co-Authored-By:') or line.startswith('#'):
+        return False
+    return True
+
+
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description=help_message)
     parser.add_argument('input', nargs='?',
@@ -350,7 +356,7 @@ if __name__ == '__main__':
                                     args.fill_up_bug_titles, args.pr_numbers)
         if args.changelog:
             lines = open(args.changelog).read().split('\n')
-            start = list(takewhile(lambda l: not l.startswith('#'), lines))
+            start = list(takewhile(skip_line_in_changelog, lines))
             end = lines[len(start):]
             with open(args.changelog, 'w') as f:
                 if not start or not start[0]:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-17 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 13:33 [gcc(refs/users/marxin/heads/commit-mklog-add-co)] commit-mklog: Add --co argument Martin Liska
  -- strict thread matches above, loose matches on Subject: below --
2021-08-17 13:10 Martin Liska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).