Skip to content
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

--blob-exec. Improved code originally developed by Paul Draper #213

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dmgerman
Copy link

@dmgerman dmgerman commented May 2, 2017

hi Roberto,

I have improved the code by Paul Draper. The main issue is that his original code did not properly wait for the children to complete. This lead to a crash under linux (see #169).

I also added the ability to specify a regular expression to indicate the files that should be processed (my own bias, since I don't like file masks, as they are not
as powerful as regexps). I have been using this patch to process several large repos (including linux and git) and it seems to be working well.

The script to execute should read the file from stdin, and output to stdout. Two environment variables are used to communicate between BFG and the script: BFG_BLOB (contains the blobid of the file to process) and BFG_FILENAME (contains the basename, including extension) of the file to process.

If the following conditions happen, the blob in the commit is not replaced:

  1. If the contents returned by the script are identical to the ones received, or
  2. The script returns an error code != 0

This pull request is a superset of #83 and addresses #169.

Regarding licensing: my commits are licensed under the same license as BFG. Paul Draper submitted his commits in another pull request, who I presume, licensed the patch according to the contributing guidelines (https://github.com/rtyley/bfg-repo-cleaner/blob/master/CONTRIBUTING.md)

--dmg

pauldraper and others added 3 commits April 6, 2017 01:37
It was not properly waiting for the child processes, making it to hang
under some architectures.

At this point I am hardcoding a lot of the processing (e.g. process only
.[ch]^ files
it now takes two parameters:

- the command name
- a mask

It also checks that the command name exists as a file and if no mask is
given it will abort
@yyfearth
Copy link

Could you give some examples how to use it?

  --blob-exec:<key>=<value>
                           execute the system command for each blob

What is the key and what should be the value?

@dmgerman
Copy link
Author

dmgerman commented Apr 24, 2018 via email

@yyfearth
Copy link

yyfearth commented May 29, 2018

@dmgerman I tried your RP with conflicts resolved with latest master.
It getting compiled, and all other functions works, but the added blobexec cannot getting though:

bfg --blob-exec:clean=js$ connector.git
command clean mask js$
Error: Option --blob-exec failed when given 'clean=js$'. None.get

@dmgerman
Copy link
Author

dmgerman commented May 29, 2018 via email

@yyfearth
Copy link

@dmgerman No difference, I tried both without $ or quoted. Always None.get

@dmgerman
Copy link
Author

dmgerman commented May 29, 2018 via email

@yyfearth
Copy link

@dmgerman The command works on git dir, but got another error:

Cleaning commits:        59% (161/272)Exception in thread "Thread-1686" java.io.IOException: Broken pipe
	at java.base/java.io.FileOutputStream.writeBytes(Native Method)
	at java.base/java.io.FileOutputStream.write(FileOutputStream.java:355)
	at java.base/java.io.BufferedOutputStream.write(BufferedOutputStream.java:123)
	at java.base/java.io.FilterOutputStream.write(FilterOutputStream.java:108)
	at com.madgag.git.bfg.cleaner.BlobExecModifier.writeJob$1(BlobExecModifier.scala:44)
	at com.madgag.git.bfg.cleaner.BlobExecModifier.$anonfun$execute$4(BlobExecModifier.scala:49)
	at com.madgag.git.bfg.cleaner.BlobExecModifier.$anonfun$execute$4$adapted(BlobExecModifier.scala:49)
	at scala.sys.process.ProcessBuilderImpl$Simple.$anonfun$run$2(ProcessBuilderImpl.scala:75)
	at scala.sys.process.ProcessImpl$Spawn$$anon$1.run(ProcessImpl.scala:23)

Any clue?

@dmgerman
Copy link
Author

dmgerman commented May 30, 2018 via email

@vlsi
Copy link

vlsi commented Jun 13, 2019

Note: blobexec command is nice, however it might be complicated to make the command reproducible across various operating systems.

For instance. Suppose one runs pngquant to optimize png files across all commits.
Then different versions of the tool might result in different outputs. That would be really bad since it would basically make all the forks unusable (everybody would have to clone from the new repo and manually reapply the changes).

I have implemented "blobexec" + store the result of processing, so the results could be reproduced even without running the command.
The release can be found is here: https://github.com/vlsi/bfg-repo-cleaner/releases/
A sample use can be found here (see blobExecCache/pngoptimizer subfolder): https://github.com/vlsi/jmeter-git-cleanup/blob/v2.2.0/clean_fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants