-
Notifications
You must be signed in to change notification settings - Fork 108
kernelci/build.py: Add apply_patch_mbox method #2041
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import re | ||
import shutil | ||
import tarfile | ||
import tempfile | ||
import time | ||
import urllib.parse | ||
|
||
|
@@ -321,6 +322,37 @@ def _download_file(url, dest_filename, chunk_size=1024): | |
return False | ||
|
||
|
||
def apply_patch_mbox( | ||
kdir, | ||
mbox_url, | ||
git_username="kernelci-tsc", | ||
git_email="[email protected]" | ||
): | ||
"""Download patch mbox from URL and apply with 3-way merge | ||
|
||
*kdir* is the path to a kernel source directory | ||
*mbox_url* is the URL to patch mbox content | ||
*git_username* is the username used to apply the patch | ||
*git_email* is the email used to apply the patch | ||
""" | ||
with tempfile.NamedTemporaryFile(prefix="kernel-patch-") as tmp_f: | ||
if not _download_file(mbox_url, tmp_f.name): | ||
raise FileNotFoundError(f"Error downloading patch mbox {mbox_url}") | ||
|
||
shell_cmd(""" | ||
set -e | ||
cd {kdir} | ||
git config user.name "{git_username}" | ||
git config user.email "{git_email}" | ||
Comment on lines
+345
to
+346
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No I mean, I think we should actually remove these lines. Say, if you're doing this over your working kernel source tree and you don't specify command line arguments with your current user name and email then it will replace it. And then next time you make a commit in the kernel source tree it'll be with the So it should be left to the user to manage this outside of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean it should be part of KernelCI config files or something? Sorry, I am not quite following what do you mean. Git won't allow to apply patches without There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be part of the user's Git config, yes. Or we could maybe have a separate command to set the user name and email explicitly if some CI systems need to do that, as a handy wrapper.
Yes and that's fine. If there's no user name and email configured then git will fail and the issue will be on the user to solve it. Just like running any other invalid command (say, if |
||
git am --3way {mbox_file} | ||
""".format( | ||
kdir=kdir, | ||
mbox_file=tmp_f.name, | ||
git_username=git_username, | ||
git_email=git_email | ||
)) | ||
|
||
|
||
def pull_tarball(kdir, url, dest_filename, retries, delete): | ||
if os.path.exists(kdir): | ||
shutil.rmtree(kdir) | ||
|
Uh oh!
There was an error while loading. Please reload this page.