-
Notifications
You must be signed in to change notification settings - Fork 1
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
When a pull request is sent, ".backup" files are incorrectly added #32
Comments
Merged
Not fixed yet. |
Might be helpful def cleanup_patch(patch: str):
"""
Remove parts of the patch that modify filenames that include '.backup.' as part of the filename
"""
if not patch:
return patch
if not isinstance(patch, str):
return ""
if not patch.strip():
# skip empty patches
return ""
patch = patch.replace("\r\n", "\n")
# There might be some weird characters at the beginning of the patch
# due to some OpenHands inference command outputs
# FOR EXAMPLE:
# git diff --no-color --cached 895f28f9cbed817c00ab68770433170d83132d90
# �[A�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[C�[K0
# diff --git a/django/db/models/sql/.backup.query.py b/django/db/models/sql/.backup.query.py
# new file mode 100644
# index 0000000000..fc13db5948
# We "find" the first line that starts with "diff" and then we remove lines before it
lines = patch.split("\n")
for i, line in enumerate(lines):
if line.startswith("diff --git"):
patch = "\n".join(lines[i:])
break
lines = patch.split("\n")
cleaned_lines = []
skip_file = False
for line in lines:
if line.startswith("diff --git"):
if ".backup." in line:
skip_file = True
else:
skip_file = False
cleaned_lines.append(line)
elif not skip_file:
cleaned_lines.append(line)
patch = "\n".join(cleaned_lines)
patch = patch.rstrip() + "\n" # Make sure the last line ends with a newline
return patch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When we create a patch, it adds a bunch of ".backup" files to the repository, which is undesirable.
This is probably due to whatthepatch not disabling the creation of the backup files.
The text was updated successfully, but these errors were encountered: