All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Cc: Kees Cook <keescook@chromium.org>, tools@linux.kernel.org
Subject: [PATCH 2/2] patchwork-bot: Add --pwhash for debugging
Date: Thu,  2 Dec 2021 15:38:36 -0800	[thread overview]
Message-ID: <20211202233836.2024510-3-keescook@chromium.org> (raw)
In-Reply-To: <20211202233836.2024510-1-keescook@chromium.org>

Finding a 2-character whitespace difference between patches with different
patchwork hashes strained my sanity, so I want to keep the tooling I
built to track it down. Using "--pwhash PATCH-ID", patchwork-bot will
compare the given patch in patchwork (and its hash) against the diff
from stdin (and its hash).

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 git-patchwork-bot.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/git-patchwork-bot.py b/git-patchwork-bot.py
index 4e10385de629..980928cf7b60 100755
--- a/git-patchwork-bot.py
+++ b/git-patchwork-bot.py
@@ -1363,6 +1363,8 @@ if __name__ == '__main__':
                         help='Domain to use when creating message-ids')
     parser.add_argument('--ancestors', default=None,
                         help='During initial database creation, consider this many ancestor commits as fresh')
+    parser.add_argument('--pwhash', default=None, type=int, metavar='PATCH-ID',
+                        help='Debug pwhash mismatches. Compare patchwork hash of diff from stdin to patch id')
 
     cmdargs = parser.parse_args()
 
@@ -1411,6 +1413,24 @@ if __name__ == '__main__':
     if not os.path.isdir(CACHEDIR):
         os.makedirs(CACHEDIR, exist_ok=True)
 
+    if cmdargs.pwhash:
+        diff = sys.stdin.read()
+        pwhash = get_patchwork_hash(diff)
+        print(pwhash)
+        for pw in CONFIG['patchworks']:
+            print(f"Patchwork: {pw}")
+            for pname, psettings in CONFIG['patchworks'][pw]['projects'].items():
+                print(f"Project: {pname}")
+                project, rm, rpc, pconfig = project_by_name(pname)
+                project_id = project['id']
+                print(get_patchwork_patches_by_project_id_hash(rpc, project_id, pwhash))
+                print('-------')
+                p = rm.get_patch(cmdargs.pwhash)
+                pwdiff = p.get('diff')
+                print(pwdiff)
+                print(get_patchwork_hash(pwdiff))
+        sys.exit(0)
+
     if cmdargs.housekeeping:
         for _pserver, _sconfig in CONFIG['patchworks'].items():
             for _pname in _sconfig['projects']:
-- 
2.30.2


  parent reply	other threads:[~2021-12-02 23:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 23:38 [PATCH 0/2] patchwork-bot: Ignore empty context lines Kees Cook
2021-12-02 23:38 ` [PATCH 1/2] " Kees Cook
2021-12-16 22:11   ` Kees Cook
2021-12-17 16:17     ` Konstantin Ryabitsev
2021-12-17 16:41       ` Kees Cook
2021-12-17 17:21         ` Konstantin Ryabitsev
2021-12-02 23:38 ` Kees Cook [this message]
2021-12-13 22:30 ` [PATCH 0/2] " Konstantin Ryabitsev
2021-12-16 20:23   ` Konstantin Ryabitsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211202233836.2024510-3-keescook@chromium.org \
    --to=keescook@chromium.org \
    --cc=konstantin@linuxfoundation.org \
    --cc=tools@linux.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.