Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions lib/vcs.cf
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bundle agent git_clean(repo_path)
}

bundle agent git_stash(repo_path, stash_name)
# @brief Stash any changes (including untracked files) in repo_path
# @brief Stash any changes (including untracked files if git is capable) in repo_path
# @param repo_path Path to the clone
# @param stash_name Stash name
#
Expand All @@ -169,14 +169,31 @@ bundle agent git_stash(repo_path, stash_name)
# comment => "Stash any changes, including untracked files";
# ```
{
classes:
_stdlib_path_exists_git::
"_git_stash_supports_including_untracked_files" -> { "CFE-3383" }
expression => regcmp( ".*--include-untracked.*",
execresult( "$(paths.git) stash --help", noshell ) );

vars:
"_stash_options"
string => concat( "save ",
"--quiet ",
ifelse( "_git_stash_supports_including_untracked_files",
"--include-untracked", ""),
"$(stash_name)");

methods:
"" usebundle => git($(repo_path), "stash", 'save --quiet --include-untracked "$(stash_name)"'),
"" usebundle => git($(repo_path), "stash", $(_stash_options)),
comment => "So that we don't lose any trail of what happened and so that
we don't accidentally delete something important we stash any
changes.
Note:
1. This promise will fail if user.email is not set
2. We are respecting ignored files.";

!_stdlib_path_exists_git::
"Warning: bundle '$(this.bundle)' actuated, but git not found";
}

bundle agent git_stash_and_clean(repo_path)
Expand Down