Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
62d7e6b0
Commit
62d7e6b0
authored
Apr 11, 2013
by
Jesús García Crespo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add --depth support in the git module
parent
0be04d2b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
library/git
+19
-6
No files found.
library/git
View file @
62d7e6b0
...
...
@@ -56,6 +56,14 @@ options:
- If C(yes), any modified files in the working
repository will be discarded. Prior to 0.7, this was always
'yes' and could not be disabled.
depth:
required: false
default: null
version_added: "1.2"
description:
- Create a shallow clone with a history truncated to the specified
number or revisions. The minimum possible value is C(1), otherwise
ignored.
examples:
- code: "git: repo=git://foosball.example.org/path/to/repo.git dest=/srv/checkout version=release-0.22"
description: Example git checkout from Ansible Playbooks
...
...
@@ -74,7 +82,7 @@ def get_version(dest):
sha
=
sha
[
0
]
.
split
()[
1
]
return
sha
def
clone
(
module
,
repo
,
dest
,
remote
):
def
clone
(
module
,
repo
,
dest
,
remote
,
depth
):
''' makes a new git repo if it does not already exist '''
dest_dirname
=
os
.
path
.
dirname
(
dest
)
try
:
...
...
@@ -82,8 +90,11 @@ def clone(module, repo, dest, remote):
except
:
pass
os
.
chdir
(
dest_dirname
)
return
module
.
run_command
(
"git clone -o
%
s
%
s
%
s"
%
(
remote
,
repo
,
dest
),
check_rc
=
True
)
cmd
=
[
module
.
get_bin_path
(
'git'
,
True
),
'clone'
,
'-o'
,
remote
]
if
depth
:
cmd
.
extend
([
'--depth'
,
str
(
depth
)
])
cmd
.
extend
([
repo
,
dest
])
return
module
.
run_command
(
cmd
,
check_rc
=
True
)
def
has_local_mods
(
dest
):
os
.
chdir
(
dest
)
...
...
@@ -92,7 +103,7 @@ def has_local_mods(dest):
lines
=
filter
(
lambda
c
:
not
re
.
search
(
'^
\\
?
\\
?.*$'
,
c
),
lines
)
return
len
(
lines
)
>
0
def
reset
(
module
,
dest
,
force
):
def
reset
(
module
,
dest
,
force
):
'''
Resets the index and working tree to HEAD.
Discards any changes to tracked files in working
...
...
@@ -251,7 +262,8 @@ def main():
repo
=
dict
(
required
=
True
,
aliases
=
[
'name'
]),
version
=
dict
(
default
=
'HEAD'
),
remote
=
dict
(
default
=
'origin'
),
force
=
dict
(
default
=
'yes'
,
type
=
'bool'
)
force
=
dict
(
default
=
'yes'
,
type
=
'bool'
),
depth
=
dict
(
default
=
None
,
type
=
'int'
),
),
supports_check_mode
=
True
)
...
...
@@ -261,6 +273,7 @@ def main():
version
=
module
.
params
[
'version'
]
remote
=
module
.
params
[
'remote'
]
force
=
module
.
params
[
'force'
]
depth
=
module
.
params
[
'depth'
]
gitconfig
=
os
.
path
.
join
(
dest
,
'.git'
,
'config'
)
...
...
@@ -273,7 +286,7 @@ def main():
if
not
os
.
path
.
exists
(
gitconfig
):
if
module
.
check_mode
:
module
.
exit_json
(
changed
=
True
)
(
rc
,
out
,
err
)
=
clone
(
module
,
repo
,
dest
,
remote
)
(
rc
,
out
,
err
)
=
clone
(
module
,
repo
,
dest
,
remote
,
depth
)
else
:
# else do a pull
local_mods
=
has_local_mods
(
dest
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment