[coreboot-gerrit] New patch to review for coreboot: util/gitconfig: add cborg2cros.pl script

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Thu Jun 23 00:02:20 CEST 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15323

-gerrit

commit b505c66161ce97ec34ce32a961cacf8f188d7926
Author: Martin Roth <martinroth at google.com>
Date:   Wed Jun 22 16:01:42 2016 -0600

    util/gitconfig: add cborg2cros.pl script
    
    This is a perl script that does basically the same thing as the
    rebase.sh script, but in the other direction.  rebase.sh takes files
    from the chromium tree (cros) and pulls them to the coreboot.org tree.
    cborg2cros, as the name implies, updates patches to go into the cros
    tree from coreboot.
    
    It adds the 'UPSTREAM: ' identifier to the start of the commit message,
    and uses the text '(cherry-picked from commit #####)' instead of
    'Original-Commit-Id: #####'
    
    Change-Id: Ibad9a5f0d0d2c713cf08e103c463e2e82768c436
    Signed-off-by: Martin Roth <martinroth at google.com>
---
 util/gitconfig/cborg2cros.pl | 67 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/util/gitconfig/cborg2cros.pl b/util/gitconfig/cborg2cros.pl
new file mode 100755
index 0000000..43e05f4
--- /dev/null
+++ b/util/gitconfig/cborg2cros.pl
@@ -0,0 +1,67 @@
+#!/usr/bin/perl
+
+#
+# This file is part of the coreboot project.
+#
+# Copyright (C) 2016 Google, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# perltidy -l=123
+
+package cborg2cros;
+
+use strict;
+use warnings;
+use English qw( -no_match_vars );
+
+my $branch = 'cborg/master';
+my $change_id;
+my @commit_message=`git log -n 1 | grep "^    " | cut -c5-`;
+my $new_commit_message;
+
+my $user_id = `git config user.name` . " <" . `git config user.email` . ">";
+$user_id =~ s/\n//g;
+
+while ( my $line = shift @commit_message ) {
+
+    # Add the upstream comment to the title
+    if ( !$new_commit_message ) {
+        $line = "UPSTREAM: $line";
+    }
+
+    # grab the Change ID
+    if ( $line =~ /^Change-Id: (.*)$/ ) {
+        $change_id = $1;
+    }
+
+    # Backslash all quotes
+    $line =~ s/"/\\"/g;
+
+    # Add 'Original-' to all of the coreboot.org gerrit messages
+    if ( $line =~ /^(Signed-off-by|Reviewed-on|Reviewed-by)/ ) {
+        $line = "Original-$line";
+    }
+
+    # Remove uninteresting gerrit messages
+    if ( $line =~ /^Tested-by/ ) {
+        next;
+    }
+
+    $new_commit_message .= $line;
+}
+
+my $commit_id = `git log -n1 --grep "$change_id" --pretty=%H $branch`;
+$commit_id =~ s/\n//g;
+
+$new_commit_message .= "(cherry-picked from commit $commit_id)\n";
+$new_commit_message .= "Signed-off-by: $user_id\n";
+
+`echo \"$new_commit_message\" | git commit --amend -F - `;



More information about the coreboot-gerrit mailing list