git-filter-repo icon indicating copy to clipboard operation
git-filter-repo copied to clipboard

feat: demo script to proc and replace files with shell commands

Open ankostis opened this issue 2 years ago • 3 comments

Adapted from lint-histoty.py demo, but command's output can be a different file which is added in the history, and optionally replaces completely the source file.

For context, I needed this one to post-process my jupyterlab notebooks (json-files) and convert them into py:percent regular python files with jupytext so as git-diff to work decently.

ankostis avatar May 08 '23 17:05 ankostis

Is there something i can do to approve CI workflow for this PR?

ankostis avatar May 12 '23 09:05 ankostis

Could there be a way to add this functionality to the original lint-history with a flag?

huyz avatar Apr 24 '24 07:04 huyz

Sorry for the long delay.

This PR is very interesting. I think @huyz's comment is a good one, though: this would give us a very heavy amount of code duplication (and even a copy of a now-obsolete large comment block) between lint-history and your script. While you make several stylistic changes throughout, those stylistic changes are equally applicable to lint-history and we really should probably either have both take the new style or both take the old style (to be determined individually for each stylistic change). From a high level point of view, though, namely from the user's perspective, your script really is just lint-history with two additional parameters (--outfpath && --drop-src). As such, I think it'd be better to structure it as an extension to that file.

Also, the commit message looks like it got mangled.

But, at an even higher level, why is this script needed? Users could already run e.g.

lint-history --relevant 'return filename.lower().endswith(b".ipynb")' -- jupytext --to 'py:percent'
git filter-repo --filename-callback 'return filename[:-6] + b".py" if filename.lower().endswith(b".ipynb") else filename'

In other words, modify the contents by calling lint-history, and then rename in a separate step (using git filter-repo).

newren avatar Jul 07 '24 02:07 newren