-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pre-commit: Ignore time stamps in po files #708
base: 2.5
Are you sure you want to change the base?
Conversation
…ing ignore_pot_creation_date.py from #708
…p has changed It helps to create meaningful commits, instead of up to 4100 changed files.
8a6c2dc
to
f55ece4
Compare
f55ece4
to
a63a82d
Compare
It has been used here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🤷 @Holzhaus you're know python better than me, do you have time for a quick look?
) | ||
|
||
|
||
def revert_po_file(changeset, po_file, logger): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes no sense to pass a logger here, getLogger is cheap
proc = subprocess.run(cmd, capture_output=True, text=True) | ||
proc.check_returncode() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like you want this:
proc = subprocess.run(cmd, capture_output=True, text=True) | |
proc.check_returncode() | |
output = subprocess.check_output(cmd, text=True) |
) | ||
parser.add_argument("--from-ref", help="Use changes since this commit.") | ||
parser.add_argument("--to-ref", help="Use changes until this commit.") | ||
parser.add_argument("files", nargs="*", help="Only check these files.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser.add_argument("files", nargs="*", help="Only check these files.") | |
parser.add_argument("files", nargs="*", type=pathlib.Path, help="Only check these files.") |
return f"{from_ref}...{to_ref}" if to_ref else from_ref | ||
|
||
|
||
def count_meaningful_changes(changeset, po_file) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def count_meaningful_changes(changeset, po_file) -> int: | |
def count_meaningful_changes(changeset: str, po_file: typing.Iterable[pathlib.Path]) -> int: |
proc = subprocess.run(cmd, capture_output=True, text=True) | ||
proc.check_returncode() | ||
|
||
with open(po_file, "w") as file: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if po_file
is a Path, you can do this:
with open(po_file, "w") as file: | |
with po_file.open(mode="w") as file: |
# Remove the first entry which is the script file name itself | ||
files_to_process = args.files[1:] if args.files else [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct. Are you confusing this with sys.argv
?
I revert normally manually time stamp only changes, to avoid cluttering a commit wit 4100 changed files. This is tedious and error prone. This PR automates it.