diff --git a/tests/visual/test_check_outdated_articles.py b/tests/visual/test_check_outdated_articles.py index ad6f027..d625640 100644 --- a/tests/visual/test_check_outdated_articles.py +++ b/tests/visual/test_check_outdated_articles.py @@ -32,6 +32,29 @@ def check_outdated_articles_test(): outdater.main("--base-commit", commit_hash) +def check_outdated_articles_test_no_recommend_autofix(): + with DummyRepository() as root: + article_paths = [ + 'wiki/Article/en.md', + 'wiki/Article/fr.md', + 'wiki/Article/fil.md', + 'wiki/Article/pt-br.md', + 'wiki/Article/zh-tw.md', + ] + + utils.create_files(root, *((path, '# Article') for path in article_paths)) + utils.stage_all_and_commit("add articles") + + utils.create_files(root, *( + (article_path, '# Article\n\nThis is an article in English.') for article_path in + utils.take(article_paths, "en.md") + )) + utils.stage_all_and_commit("modify english article") + commit_hash = utils.get_last_commit_hash() + + outdater.main("--no-recommend-autofix", "--base-commit", commit_hash) + + test = VisualTest( name="Check outdated articles", description="This should complain about translations not being outdated properly", @@ -40,6 +63,11 @@ def check_outdated_articles_test(): name="non_outdated_articles", description="Non-outdated articles (4 errors)", function=check_outdated_articles_test + ), + VisualTestCase( + name="non_outdated_articles", + description="Non-outdated articles with --no-recommend-autofix (4 errors)", + function=check_outdated_articles_test_no_recommend_autofix ) ] ) diff --git a/wikitools_cli/VERSION.py b/wikitools_cli/VERSION.py index b777579..3c00bb4 100644 --- a/wikitools_cli/VERSION.py +++ b/wikitools_cli/VERSION.py @@ -1 +1 @@ -VERSION = "2.1.2" +VERSION = "2.2.0" diff --git a/wikitools_cli/commands/check_outdated_articles.py b/wikitools_cli/commands/check_outdated_articles.py index 0bad165..bc8ad14 100644 --- a/wikitools_cli/commands/check_outdated_articles.py +++ b/wikitools_cli/commands/check_outdated_articles.py @@ -35,11 +35,11 @@ AUTOCOMMIT_FLAG_SHORT = "-c" -def print_translations_to_outdate(*filenames, outdated_hash=None, workflow=False): +def print_translations_to_outdate(*filenames, outdated_hash=None, no_recommend_autofix=False): print(f"{console.red('Error:')} You have edited some original articles (en.md), but did not outdate their translations:") print("\n".join(console.red(f"* {filename}") for filename in filenames)) print(f"\nIf your changes DON'T NEED to be added to the translations, add {console.red(PULL_REQUEST_TAG)} anywhere in the description of your pull request.") - if not workflow: + if not no_recommend_autofix: print( f"Otherwise, rerun the script with {console.green(AUTOFIX_FLAG)} (and perhaps {console.green(AUTOCOMMIT_FLAG)}), or " "add the following to each article's front matter (https://osu.ppy.sh/wiki/en/Article_styling_criteria/Formatting#front-matter):" @@ -77,7 +77,7 @@ def parse_args(args): parser.add_argument(f"{AUTOFIX_FLAG_SHORT}", f"{AUTOFIX_FLAG}", default=False, action="store_true", help=f"automatically add `{OUTDATED_HASH_TAG}: {{hash}}` to outdated articles") parser.add_argument(f"{AUTOCOMMIT_FLAG_SHORT}", f"{AUTOCOMMIT_FLAG}", default=False, action="store_true", help=f"automatically commit changes") parser.add_argument("-r", "--root", help="specify repository root, current working directory assumed otherwise") - parser.add_argument("--workflow", action='store_true', help="whether the script is run from a github workflow") + parser.add_argument("--no-recommend-autofix", action='store_true', help=f"don't recommend rerunning the script with {AUTOFIX_FLAG}") return parser.parse_args(args) @@ -151,9 +151,7 @@ def main(*args): if args.root: changed_cwd = file_utils.ChangeDirectory(args.root) - base_commit = args.base_commit - if not args.workflow and not base_commit: - base_commit = git_utils.get_first_branch_commit() + base_commit = args.base_commit or git_utils.get_first_branch_commit() if not base_commit and not args.all: print(f"{console.red('Error:')} neither --base-commit (unable to obtain automatically) nor --all were specified; nothing to do.") @@ -210,7 +208,7 @@ def main(*args): for file_path in translations_to_outdate: print(console.green(f"* {file_path}")) else: - print_translations_to_outdate(*translations_to_outdate, outdated_hash=outdated_hash, workflow=args.workflow) + print_translations_to_outdate(*translations_to_outdate, outdated_hash=outdated_hash, no_recommend_autofix=args.no_recommend_autofix) exit_code = 1 else: