| #!/usr/bin/python3 |
| # SPDX-License-Identifier: GPL-2.0-or-later |
| # Copyright 2023 Google LLC |
| |
| import argparse |
| |
| from stable_utils import * |
| |
| parser = argparse.ArgumentParser( |
| formatter_class=argparse.RawDescriptionHelpFormatter, |
| description= |
| """Finds the original patch email from a git commit. Uses the message ID from |
| the commit message if possible, otherwise falls back to a search of |
| lore.kernel.org by commit title.""") |
| parser.add_argument('commit_id') |
| parser.add_argument('--msgid', action='store_true', |
| help='just output the message ID') |
| parser.add_argument('--link', action='store_true', |
| help='just output a lore link') |
| args = parse_args(parser) |
| |
| commit = Commit(args.commit_id) |
| message_id = commit.find_original_email() |
| if not message_id: |
| error(f'Cannot find original patch for {commit}') |
| |
| if args.msgid: |
| print(message_id) |
| elif args.link: |
| print(f'{config.lore}/r/{message_id}') |
| else: |
| raw_message = fetch_raw_message(message_id) |
| sys.stdout.buffer.write(raw_message) |