Commit Graph

54 Commits (76260d3aa88856add595c40b9485d363f7d6595b)

Author SHA1 Message Date
Rob Cutmore 09b06a601c Git: Determine if remote URL is being changed (#4243)
* Git: Determine if remote URL is being changed

Ansible reported there were no changes when only the remote URL for a
repo was changed. This properly tracks and reports when the remote URL
for a repo changes.

Fixes #4006

* Fix handling of local repo paths

* Git: Use newer method for fetching remote URL

* Git: use ls-remote to fetch remote URL

Using ls-remote to fetch remote URL is supported in earlier versions
of Git compared to using remote command.

* Maintain previous behavior for older Git versions

Previously whether or not the remote URL changed was not factored
into command's changed status. Git versions prior to 1.7.5 lack the
functionality used for fetching a repo's remote URL so these versions
will update the remote URL without affecting the changed status.
2016-12-08 11:24:50 -05:00
jctanner 634b1024d6 git: save changed submodules in check and non-check mode (#4392) 2016-12-08 11:24:49 -05:00
Dag Wieers 4ee9cc4b3f Add diff mode support to git module (#3364)
* Add diffmode support to git module

This patch adds missing diffmode support to the git module.

* Remodel get_diff() and calls to it

As proposed by @abadger

* Ensure we fetch the required object before performing a diff

Also we handle the return code ourselves, so don't leave this up to run_command().
2016-12-08 11:24:49 -05:00
Robin Roth 5d928ca13c Fix git shallow update (#3912)
* remove unused variables

* fetch branch name instead of HEAD

fix #3782, which was introduced by f1bacc1d3f9578f26d4ae2f66112cbb2509a7fe8

* disable git depth option for old git versions

fixes #3782
git support for `--depth` did not fully work in old git versions (before 1.8.2)
fall back to full clones/fetches on those versions

* raise required git version to 1.9.1 for depth option

* use correct depth argument in switch_version
2016-12-08 11:24:41 -05:00
Toshio Kuratomi eadef56a06 Add comment 2016-12-08 11:24:38 -05:00
Marius Gedminas 3a8a11d85f git: fix change testing when version is HEAD (#3025)
When `version` is not specified, it defaults to "HEAD".  "HEAD" is not a
remote tag, and it's not listed in the output of get_branches(), so we'd
keep repo_updated at the default value (None) and then return early with
changed=True in --check mode, even when before == after.

Fixes #3024.
2016-12-08 11:24:38 -05:00
Toshio Kuratomi b259c65b20 Revert "Fix git shallow update (#3794)" -- Broke integration tests: https://app.shippable.com/runs/57599a7897ae890c00c2898d
This reverts commit c26eb1217fae8703a7b9cd8ae708051c58fc9273.
2016-12-08 11:24:36 -05:00
Robin Roth 513c3bf287 Fix git shallow update (#3794)
* remove unused variables

* fetch branch name instead of HEAD

fix #3782, which was introduced by f1bacc1d3f9578f26d4ae2f66112cbb2509a7fe8

* disable git depth option for old git versions

fixes #3782
git support for `--depth` did not fully work in old git versions (before 1.8.2)
fall back to full clones/fetches on those versions
2016-12-08 11:24:36 -05:00
Michael Scherer 82df6f981e Improve error reporting when git binary fail (#3266)
Showing stderr or stdout is a great help to understand
when something go south.
2016-12-08 11:24:30 -05:00
Michael Scherer 54c71b9331 Add a better solution for the ssh_known_hosts issue
Fix https://github.com/ansible/ansible/issues/10172 too
2016-12-08 11:24:25 -05:00
Robin Roth 281398fdc2 fix git switch branches in combination with depth on old git versions (#3492)
* fix git switch branches in combination with depth

* the old implementation is correct, but relies on git working correctly
  (as only newer versions do)
* with some older git version (e.g. 1.8.3), git fetch remote branch does
  not work, if the branch does not yet exist locally
* this patch works around that without explicitly checking the git version
* future refactoring is needed to reduce the number of fetches to a
  minimum; but this patch makes the code "correct"

* add git version requirements to doc

* replace set-branches with git 1.7.1 compatible version
2016-12-08 11:24:20 -05:00
Rene Moser 885b8dc4d0 git: fix status to use porcelain, ignore user configuration
From the git status doc:

    --porcelain

        Give the output in an easy-to-parse format for scripts. This is similar to the short output, but will remain stable across Git versions and regardless of user configuration. See below for details.

User configuration can break the git module from working as expected.
2016-12-08 11:24:20 -05:00
Robin Roth c7cb1b28cd fall back to full clone if version is hash
if version is not a branch or tag (i.e. a hash), we need a full checkout to be able to switch to it
2016-12-08 11:24:19 -05:00
Robin Roth 8e5e5108d1 with depth only fetch actual version
* don't use refs/heads/branchname for branches
* for tags it's needed thou
* fixes #3456
2016-12-08 11:24:19 -05:00
Kyle Dyroff 58f30646ed Log git error stdout/stderr to fail_json (#3022) 2016-12-08 11:24:18 -05:00
Robin Roth b9e55a0877 make git updates respect depth (#3254)
* make git updates respect depth

until now `fetch` gets all tags and heads at full depth, this change
* uses `depth` argument for `fetch`
* only get the specified `version` in `fetch`

* fixes #14954

* treat combination of refspec and depth correctly

* be more conservative for non-depth fetch
2016-12-08 11:24:18 -05:00
Toshio Kuratomi 40948cfcc4 git still needs to have abspath applied to dest 2016-12-08 11:24:16 -05:00
Michael Scherer 3d415ac2da Use type='path' for path arguments for git module 2016-12-08 11:24:14 -05:00
Toshio Kuratomi f8f84f0491 Since we screenscrape output from git to tell us information we need to use the C locale when running commands.
Using another locale would mean that we get information that may have
the strings that we are looking for.

Fixes #2449
Fixes #2462
2016-12-08 11:24:03 -05:00
Jordan Bach b6213ffa80 git: set remote branch before switching versions when using depth argument 2016-12-08 11:23:59 -05:00
Jan Duzinkiewicz 9c6db69827 forcing git fetch if sha1 are equal between repos but branch exists only at remote
Add an explanatory comment to the code
2016-12-08 11:23:57 -05:00
Dmitry Labutin 60b1273d55 Github uses both HTTP and HTTPS protocols 2016-12-08 11:23:56 -05:00
Chris Streeter 04b52efb64 Fix name of ssh_opts arg 2016-12-08 11:23:48 -05:00
Andrew Widdersheim 7d174daa77 Fix detached head detection in is_not_a_branch()
Detached head detection seems to have broken somewhere a long the way
because git decided to change how that situation looks when doing a 'git
branch -a' which is performed by get_branches().

This is how git 1.7.1 displays this situation (which works):

shell> git branch -a
* (no branch)
  master

This is the output from git 1.8.3.1 (which does not work):

shell> git branch -a
* (detached from e132711)
  master

It looks like this same wording is used in the most recent version of
git (2.6.1 as of writing this).
2016-12-08 11:23:39 -05:00
Jan Inowolski 3d45384aed update git remote url before ls-remote
related to #8177
2016-12-08 11:23:28 -05:00
Brian Coca b261fd8d3e added doc to note that git the command line tool is required for this moduel to function fixes http://github.com/ansible/ansible/issues/11358 2016-12-08 11:23:14 -05:00
Greg DeKoenigsberg eb881d7d5d Proper author info for all remaining modules 2016-12-08 11:23:07 -05:00
Brian Coca 3d42d8897e fixed doc issue with git 2016-12-08 11:23:06 -05:00
Dionysis Grigoropoulos 59f7db899d git: Add option to verify GPG signature of commit 2016-12-08 11:23:05 -05:00
Toshio Kuratomi 49f5b28fbd Change the git force parameter to default to no as a safety change.
Fixes #306
2016-12-08 11:22:40 -05:00
Toshio Kuratomi 1be539d870 git fetch --tags overwrites normal fetching with git < 1.8.x so do a normal fetch followed by using the refspec format for fetching tags 2016-12-08 11:22:34 -05:00
Toshio Kuratomi 73b7d6ea7b Fix typo in git refspec code. Change lists to tuples 2016-12-08 11:22:34 -05:00
Toshio Kuratomi 5c090207ff Make documentation clear about update=no vs clone=no 2016-12-08 11:22:34 -05:00
Rohan McGovern b607ffb7c6 git: add 'refspec' argument
This argument may be used to fetch additional refs beyond the default
refs/heads/* and refs/tags/*.  Checking out GitHub pull requests or Gerrit
patch sets are two examples where this is useful.

Without this, specifying version=<sha1> with a SHA1 unreachable from any
tag or branch can't work.
2016-12-08 11:22:34 -05:00
Rohan McGovern 06ff34f364 git: clean up "fetch" method
De-duplicate repetitive code checking the exit code.

Include the stdout/stderr of the failed process in all cases.

Remove the returned values because no caller uses them.

Combine git commands where possible.  There is no need to fetch branches
and tags as two separate operations.
2016-12-08 11:22:34 -05:00
Toshio Kuratomi 8af70de1fc Probably would make clone a 1.9 feature rather than 1.8.3 2016-12-08 11:22:33 -05:00
Toshio Kuratomi a7ff6c4cba Make git's update parameter revert to its old behaviour and add new clone parameter to take its place.
Fixes #426
Fixes https://github.com/ansible/ansible/issues/8630
2016-12-08 11:22:33 -05:00
Toshio Kuratomi 123c99f879 Add error message from git to message returned from ansible
Fixes #81
2016-12-08 11:22:33 -05:00
Toshio Kuratomi 88ccfc219a Change git update param documentation to match reality 2016-12-08 11:22:32 -05:00
Toshio Kuratomi 8b586ad055 Before pulling submodules from repos add ssh hostkeys for those submodules
Fixes #9655
2016-12-08 11:22:32 -05:00
Toshio Kuratomi 6f3f0904eb Fix git mod so that we switch to the desired version even if it was previously downloaded 2016-12-08 11:22:32 -05:00
Toshio Kuratomi 59066f6138 Some cleanups to the git module 2016-12-08 11:22:32 -05:00
Toshio Kuratomi fc15177e6e Revert git module doc update because it appears ssh:// works and bare ssh repo does not
This reverts commit e715909831e27cbfed2ae86e886bf154cefd7b6c.
2016-12-08 11:22:31 -05:00
Lorin Hochstein 0cf3cfbf5a git doc: don't prepend ssh:// for ssh repo
The github ssh example has ssh:// at the beginning of the url. However, this doesn't
work. It does work if the ssh:// is removed.
2016-12-08 11:22:31 -05:00
Jérémie Astori c52bfe3e35 Fix #91: Expand user home folder for the key_file path of the git module 2016-12-08 11:22:30 -05:00
Antti Salminen 75e15e2ae9 Find the actual commit annotated tags refer to instead of the tag object. 2016-12-08 11:22:29 -05:00
Toshio Kuratomi b00e6464e9 Fix cornercase tracebaxk when detecting whether submodules changed 2016-12-08 11:22:28 -05:00
Toshio Kuratomi 3e09de7aef Fix git module checking out correct version after initial clone
Fixes #313
2016-12-08 11:22:27 -05:00
Toshio Kuratomi dfd4433fba Fix git module handling of the recursive flag
Fixes: #169
2016-12-08 11:22:24 -05:00
Toshio Kuratomi 5fc463eee7 Update desctiprion, parameter name, and default value as discussed in #55 2016-12-08 11:22:24 -05:00