Skip to content

Commit

Permalink
rename --workflow to --no-recommend-autofix and change behaviour slig…
Browse files Browse the repository at this point in the history
…htly
  • Loading branch information
Walavouchey committed Dec 1, 2023
1 parent 9ceb05b commit e101c24
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
28 changes: 28 additions & 0 deletions tests/visual/test_check_outdated_articles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
)
]
)
2 changes: 1 addition & 1 deletion wikitools_cli/VERSION.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "2.1.2"
VERSION = "2.2.0"
12 changes: 5 additions & 7 deletions wikitools_cli/commands/check_outdated_articles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):"
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e101c24

Please sign in to comment.