From 11455bc0f546ec01bf4f7d72054ba0dbabbde0e0 Mon Sep 17 00:00:00 2001 From: Jerry Zhang Date: Tue, 18 Jul 2023 19:30:10 -0700 Subject: [PATCH] amend: Force editing if inserting instead of throwing error If a user has configured edit=False but specifies --insert, the intention is clear enough that they do in fact want to edit. We can automatically assume this without throwing an error and forcing them to type out --edit --- docs/amend.md | 4 ++-- revup/amend.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/amend.md b/docs/amend.md index f2e3afd..3c840f1 100644 --- a/docs/amend.md +++ b/docs/amend.md @@ -48,8 +48,8 @@ use the old commit message as-is. **--insert, -i** : Instead of amending the given commit, insert the changes in cache as a new commit after the given commit. If there are no changes in -cache, this inserts an empty commit. Cannot be used with --no-edit, -since the new commit requires a commit message. +cache, this inserts an empty commit. Implies --edit, since the new commit +requires a commit message. **--drop, -d** : Instead of amending the given commit, drop it and leave any changes diff --git a/revup/amend.py b/revup/amend.py index 960356c..c38df8c 100644 --- a/revup/amend.py +++ b/revup/amend.py @@ -110,11 +110,10 @@ async def get_has_unstaged() -> bool: get_has_unstaged(), ) + args.edit = args.edit or args.insert has_diff = has_staged or has_unstaged or args.drop if not has_diff and not args.edit: return 0 - if args.insert and not args.edit: - raise RevupUsageException("Can't skip wording an inserted commit!") if args.drop and args.insert: raise RevupUsageException("Doesn't make sense to drop and insert")