Git State and Execution Modules Rewritten#
The git state and execution modules have gone through an extensive overhaul.
Changes in the git.latest State#
The
branchargument has been added, allowing for a custom branch name to be used in the local checkout maintained by thegit.lateststate. This can be helpful in avoiding ambiguous refs in the local checkout when a tag is used as therevargument. If nobranchis specified, then the state uses the value ofrevas the branch name.The
always_fetchargument no longer has any effect, and will be removed in a future release. The state now detects whether or not a fetch is needed based on comparisons made between the local and remote repositories.The
force_fetchargument has been added to force a fetch if the fetch is not a fast-forward (for instance, if someone has done a reset and force-pushed to the remote repository).The
remote_nameargument has been deprecated and renamed toremote.The
forceargument has been deprecated and renamed toforce_cloneto reduce ambiguity with the other "force" arguments.Using SHA1 hashes (full or shortened) in the
revargument is now properly supported.Non-fast-forward merges are now detected before the repository is updated, and the state will not update the repository if the change is not a fast-forward. Non-fast-forward updates must be overridden with the
force_resetargument. Ifforce_resetis set toTrue, the state will only reset the repository if it cannot be fast-forwarded. This is in contrast to the earlier behavior, in which a hard-reset would be performed every time the state was run ifforce_resetwas set toTrue.A
git pullis no longer performed by this state, dropped in favor of a fetch-and-merge (or fetch-and-reset) workflow.
git.config_unset state added#
This state allows for configuration values (or entire keys) to be unset. See
here for more information and example
SLS.
git.config State Renamed to git.config_set#
To reduce confusion after the addition of git.config_unset, the git.config state has been renamed to
git.config_set. The old config.get name
will still work for a couple releases, allowing time for SLS files to be
updated.
In addition, this state now supports managing multivar git configuration
values. See here for more information
and example SLS.
Initial Support for Git Worktrees in Execution Module#
Several functions have been added to the execution module to manage worktrees (a feature new to Git 2.5.0). State support does not exist yet, but will follow soon.
New Functions in Git Execution Module#
Changes to Functions in Git Execution Module#
git.add#
--verboseis now implied when running thegit addcommand, to provide a list of the files added in the return data.
git.archive#
Now returns
Truewhen thegit archivecommand was successful, and otherwise raises an error.The
overwriteargument has been added to prevent an existing archive from being overwritten by this function.The
fmtargument has been deprecated and renamed toformat.Trailing slash no longer implied in
prefixargument, must be included if this argument is passed.
git.checkout#
The
revargument is now optional when using-bor-Binopts, allowing for a branch to be created (or reset) usingHEADas the starting point.
git.clone#
The
nameargument has been added to specify the name of the directory in which to clone the repository. If this option is specified, then the clone will be made within the directory specified by thecwd, instead of at that location.The
repositoryargument has been deprecated and renamed tourl.
git.config_get#
The
setting_nameargument has been deprecated and renamed tokey.The
globalargument has been added, to query the global git configurationThe
allargument has been added to return a list of all values for the specified key, allowing for all values in a multivar to be returned.The
cwdargument is now optional ifglobalis set toTrue
git.config_set#
The value(s) of the key being set are now returned
The
setting_nameargument has been deprecated and renamed tokey.The
setting_valueargument has been deprecated and renamed tovalue.The
is_globalargument has been deprecated and renamed toglobal.The
multivarargument has been added to specify a list of values to set for the specified key. Thevalueargument is not compatible withmultivar.The
addargument has been added to add a value to a key (this essentially just adds an--addto thegit configcommand that is run to set the value).
git.fetch#
The
forceargument has been added to force the fetch when it is not a fast-forward. This could have been achieved in previous Salt versions by including--forcein theoptsargument, this argument is just for convenience and to match the usage of other functions withforcearguments.The
refspecsargument has been added to allow for one or more refspecs to be provided which override the one(s) specified by the remote.remote_name.fetch git configuration option.
git.ls_remote#
The
repositoryargument has been deprecated and renamed toremote.The
branchargument has been deprecated and renamed toref.The
optsargument has been added to allow for additional CLI options to be passed to thegit ls-remotecommand.
git.merge#
The
branchargument has been deprecated and renamed torev.
git.status#
Return data has been changed from a list of lists to a dictionary containing lists of files in the modified, added, deleted, and untracked states.
git.submodule#
Added the
commandargument to allow for operations other thanupdateto be run on submodules, and deprecated theinitargument. To do a submodule update withinit=Truemoving forward, usecommand=update opts='--init'.