-
-
Save lucasdemarchi/6f760270edc881e41845f69ed55eab69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/git_pile/git_pile.py b/git_pile/git_pile.py | |
index a89d090..c38a357 100755 | |
--- a/git_pile/git_pile.py | |
+++ b/git_pile/git_pile.py | |
@@ -454,6 +454,32 @@ def get_series_linenum_dict(d): | |
return series | |
+def copy_sanitized_patch(p, outputdir): | |
+ fn = op.join(outputdir, op.basename(p)) | |
+ # state_desc = [ "header", "diff header", "hunk header", "other"] | |
+ state = 0 | |
+ | |
+ with open(p, "r") as oldf: | |
+ with open(fn, "w") as newf: | |
+ for l in oldf: | |
+ if state == 0: | |
+ if l.startswith("diff"): | |
+ state = 1 | |
+ else: | |
+ newf.write(l) | |
+ if state == 1 or state == 3: | |
+ if l.startswith("@@"): | |
+ state = 2 | |
+ if state == 1: | |
+ if not l.startswith("index"): | |
+ newf.write(l) | |
+ if state == 2: | |
+ newf.write(l) | |
+ state = 3 | |
+ if state == 3: | |
+ newf.write(l) | |
+ | |
+ | |
# pre-existent patches are removed, all patches written from commit_range, | |
# "config" and "series" overwritten with new valid content | |
def genpatches(output, base_commit, result_commit): | |
@@ -492,7 +518,7 @@ def genpatches(output, base_commit, result_commit): | |
rm_patches(output) | |
for p in series: | |
- s = shutil.copy(p, output) | |
+ copy_sanitized_patch(p, output) | |
with open(op.join(output, "series"), "w") as f: | |
f.write("# Auto-generated by git-pile\n\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment