Skip to content

Commit 0f1835b

Browse files
authored
Merge pull request #1806 from nickanderson/CFE-3383/master
CFE-3383/master: Made git_stash only stash untracked files when capable
2 parents e59b7d4 + 627a8d9 commit 0f1835b

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

lib/vcs.cf

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ bundle agent git_clean(repo_path)
156156
}
157157

158158
bundle agent git_stash(repo_path, stash_name)
159-
# @brief Stash any changes (including untracked files) in repo_path
159+
# @brief Stash any changes (including untracked files if git is capable) in repo_path
160160
# @param repo_path Path to the clone
161161
# @param stash_name Stash name
162162
#
@@ -169,14 +169,31 @@ bundle agent git_stash(repo_path, stash_name)
169169
# comment => "Stash any changes, including untracked files";
170170
# ```
171171
{
172+
classes:
173+
_stdlib_path_exists_git::
174+
"_git_stash_supports_including_untracked_files" -> { "CFE-3383" }
175+
expression => regcmp( ".*--include-untracked.*",
176+
execresult( "$(paths.git) stash --help", noshell ) );
177+
178+
vars:
179+
"_stash_options"
180+
string => concat( "save ",
181+
"--quiet ",
182+
ifelse( "_git_stash_supports_including_untracked_files",
183+
"--include-untracked", ""),
184+
"$(stash_name)");
185+
172186
methods:
173-
"" usebundle => git($(repo_path), "stash", 'save --quiet --include-untracked "$(stash_name)"'),
187+
"" usebundle => git($(repo_path), "stash", $(_stash_options)),
174188
comment => "So that we don't lose any trail of what happened and so that
175189
we don't accidentally delete something important we stash any
176190
changes.
177191
Note:
178192
1. This promise will fail if user.email is not set
179193
2. We are respecting ignored files.";
194+
195+
!_stdlib_path_exists_git::
196+
"Warning: bundle '$(this.bundle)' actuated, but git not found";
180197
}
181198

182199
bundle agent git_stash_and_clean(repo_path)

0 commit comments

Comments
 (0)