diff options
author | Ryan Egesdahl <ryan.egesdahl@mongodb.com> | 2023-04-12 21:39:32 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-12 22:19:16 +0000 |
commit | 677dd87ca6f923f38dd9c5f4b1120d76203a72b7 (patch) | |
tree | d49de24de73e3591db63cd384e9c971f4a15b209 /site_scons | |
parent | 851cfd2d0aaaf3ae877608236d1aad10eedd7f9e (diff) | |
download | mongo-677dd87ca6f923f38dd9c5f4b1120d76203a72b7.tar.gz |
SERVER-70425 Stash before using git archive
Diffstat (limited to 'site_scons')
-rw-r--r-- | site_scons/site_tools/distsrc.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/site_scons/site_tools/distsrc.py b/site_scons/site_tools/distsrc.py index 83f47f2ab3f..33b63d3d8d4 100644 --- a/site_scons/site_tools/distsrc.py +++ b/site_scons/site_tools/distsrc.py @@ -20,18 +20,19 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -import SCons +import io import os import os.path as ospath -import subprocess import shutil +import subprocess import tarfile import time import zipfile -import io from distutils.spawn import find_executable +import SCons + __distsrc_callbacks = [] @@ -174,6 +175,7 @@ def distsrc_action_generator(source, target, env, for_signature): # This is done in two stages because env.WhereIs doesn't seem to work # correctly on Windows, but we still want to be able to override the PATH # using the env. + git_path = env.WhereIs("git") if not git_path: git_path = find_executable("git") @@ -192,11 +194,22 @@ def distsrc_action_generator(source, target, env, for_signature): print("Invalid file format for distsrc. Must be tar or zip file") env.Exit(1) - git_cmd = ('"%s" archive --format %s --output %s --prefix ${MONGO_DIST_SRC_PREFIX} HEAD' % - (git_path, target_ext, target[0])) + def create_archive(target=None, source=None, env=None): + stash_id = subprocess.check_output([git_path, "stash", "create"]).decode("utf-8").strip() + subprocess.check_call([ + git_path, + "archive", + "--format", + target_ext, + "--output", + str(target[0]), + "--prefix", + env["MONGO_DIST_SRC_PREFIX"], + stash_id, + ]) return [ - SCons.Action.Action(git_cmd, "Running git archive for $TARGET"), + SCons.Action.Action(create_archive, "Creating archive for $TARGET"), SCons.Action.Action( run_distsrc_callbacks, "Running distsrc callbacks for $TARGET", |