diff options
author | Kees Cook <keescook@chromium.org> | 2021-11-30 16:11:26 -0800 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-12-13 17:28:18 -0500 |
commit | 6fc2e91a876b0a2771eedb0fe6106d7f47eb8aab (patch) | |
tree | 2d3228e91222281f7839e6f8e3310029a05902ac | |
parent | 460990bdca13805f7e9b5d6c8037437f655bcfac (diff) | |
download | korg-helpers-6fc2e91a876b0a2771eedb0fe6106d7f47eb8aab.tar.gz |
patchwork-bot: Allow initial database to skip recent commits
To test patchwork-bot, it is helpful to create the initial database
without a certain number of the latest commits, so that on the next
execution, the "missing" commits will appear new, and will be used for
processing state changes. Add the --ancestors argument (defaulting to
0, the existing behavior), to provide this ability.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://lore.kernel.org/r/20211201001126.4106635-6-keescook@chromium.org
-rwxr-xr-x | git-patchwork-bot.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/git-patchwork-bot.py b/git-patchwork-bot.py index 9be945d..2ebe5b4 100755 --- a/git-patchwork-bot.py +++ b/git-patchwork-bot.py @@ -409,13 +409,17 @@ def git_run_command(gitdir, args, stdin=None): return output -def git_get_repo_heads(gitdir, branch): +def git_get_repo_heads(gitdir, branch, ancestry=None): refs = list() lines = git_get_command_lines(gitdir, ['show-ref', branch]) + if ancestry == None: + ancestry = '' + else: + ancestry = f'~{ancestry}' if lines is not None: for line in lines: (commit_id, refname) = line.split() - refs.append((refname, commit_id)) + refs.append((refname, commit_id + ancestry)) return refs @@ -1082,7 +1086,9 @@ def pwrun(repo, rsettings): if not db_exists: db_init_pw_sqlite_db(c) - db_save_repo_heads(c, git_heads) + initial_git_heads = git_get_repo_heads(repo, branch=rsettings.get('branch', '--heads'), + ancestry=cmdargs.ancestors) + db_save_repo_heads(c, initial_git_heads) # Exit early dbconn.commit() return @@ -1353,6 +1359,8 @@ if __name__ == '__main__': help='Cache directory to use instead of ~/.cache/git-patchwork-bot') parser.add_argument('--domain', default=None, 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') cmdargs = parser.parse_args() |