Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.build
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.recipe.build
Commits
5bf99121
Commit
5bf99121
authored
Aug 30, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use self.options
parent
2bfadf5e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
33 deletions
+41
-33
slapos/recipe/gitclone.py
slapos/recipe/gitclone.py
+41
-33
No files found.
slapos/recipe/gitclone.py
View file @
5bf99121
...
@@ -37,20 +37,19 @@ class Recipe(object):
...
@@ -37,20 +37,19 @@ class Recipe(object):
"""Clone a git repository."""
"""Clone a git repository."""
def
__init__
(
self
,
buildout
,
name
,
options
):
def
__init__
(
self
,
buildout
,
name
,
options
):
options
.
setdefault
(
'branch'
,
GIT_DEFAULT_BRANCH_NAME
)
self
.
url
=
options
.
get
(
'url'
)
options
.
setdefault
(
'revision'
,
''
)
self
.
branch
=
options
.
get
(
'branch'
,
GIT_DEFAULT_BRANCH_NAME
)
options
.
setdefault
(
'branch'
,
''
)
self
.
revision
=
options
.
get
(
'revision'
)
options
.
setdefault
(
'develop'
,
'false'
)
self
.
git_command
=
options
.
get
(
'git-command'
,
'git'
)
options
.
setdefault
(
'git-command'
,
'git'
)
self
.
location
=
options
.
get
(
'location'
,
options
.
setdefault
(
'location'
,
os
.
path
.
join
(
buildout
[
'buildout'
][
'parts-directory'
],
name
))
os
.
path
.
join
(
if
options
.
get
(
'develop'
)
in
TRUE_VALUES
:
buildout
[
'buildout'
][
'parts-directory'
],
self
.
develop
=
True
name
)
if
not
self
.
url
:
)
raise
ValueError
(
'url parameter is mandatory.'
)
self
.
options
=
options
if
self
.
revision
and
self
.
branch
:
if
options
[
'revision'
]
and
options
[
'branch'
]:
# revision and branch options are incompatible
# revision and branch options are incompatible
raise
ValueError
(
'revision and branch parameters are set but are'
raise
ValueError
(
'revision and branch parameters are set but are'
'incompatible. Please specify only one of them.'
)
'incompatible. Please specify only one of them.'
)
...
@@ -58,39 +57,48 @@ class Recipe(object):
...
@@ -58,39 +57,48 @@ class Recipe(object):
def
gitReset
(
self
,
revision
=
None
):
def
gitReset
(
self
,
revision
=
None
):
"""Operates git reset on the repository."""
"""Operates git reset on the repository."""
command
=
[
self
.
options
[
'git-command'
]
,
'reset'
,
'--hard'
]
command
=
[
self
.
git_command
,
'reset'
,
'--hard'
]
if
revision
:
if
revision
:
command
.
append
(
revision
)
command
.
append
(
revision
)
check_call
(
command
,
cwd
=
self
.
options
[
'location'
])
check_call
(
command
,
cwd
=
self
.
location
)
def
install
(
self
):
def
install
(
self
):
""" Do a git clone. If revision is specified, reset to it."""
"""
if
not
os
.
path
.
exists
(
self
.
options
[
'location'
]):
Do a git clone.
git_clone_command
=
[
self
.
options
[
'git-command'
],
'clone'
,
If branch is specified, checkout to it.
self
.
options
[
'url'
],
If revision is specified, reset to it.
self
.
options
[
'location'
]]
"""
if
self
.
options
[
'branch'
]:
if
not
os
.
path
.
exists
(
self
.
location
):
git_clone_command
.
extend
([
'--branch'
,
self
.
options
[
'branch'
]])
git_clone_command
=
[
self
.
git_command
,
'clone'
,
self
.
url
,
self
.
location
]
if
self
.
branch
:
git_clone_command
.
extend
([
'--branch'
,
self
.
branch
])
check_call
(
git_clone_command
)
check_call
(
git_clone_command
)
if
self
.
options
[
'revision'
]
:
if
self
.
revision
:
self
.
gitReset
(
self
.
options
[
'revision'
]
)
self
.
gitReset
(
self
.
revision
)
return
[
self
.
options
[
'location'
]
]
return
[
self
.
location
]
def
update
(
self
):
def
update
(
self
):
check_call
([
self
.
options
[
'git-command'
],
'fetch'
,
'--all'
],
"""
cwd
=
self
.
options
[
'location'
])
Do a git fetch.
If user doesn't develop, reset to remote HEAD (or revision or branch if
specified.)
"""
check_call
([
self
.
git_command
,
'fetch'
,
'--all'
],
cwd
=
self
.
location
)
# If develop parameter is set, don't reset/update.
# If develop parameter is set, don't reset/update.
# Otherwise, reset --hard
# Otherwise, reset --hard
if
not
self
.
options
.
get
(
'develop'
)
in
TRUE_VALUES
:
if
not
self
.
develop
:
if
self
.
options
[
'revision'
]
:
if
self
.
revision
:
self
.
gitReset
(
self
.
options
[
'revision'
]
)
self
.
gitReset
(
self
.
revision
)
elif
self
.
options
[
'branch'
]
:
elif
self
.
branch
:
self
.
gitReset
(
'%s/%s'
%
(
self
.
gitReset
(
'%s/%s'
%
(
GIT_DEFAULT_REMOTE_NAME
,
self
.
options
[
'branch'
]
))
GIT_DEFAULT_REMOTE_NAME
,
self
.
branch
))
else
:
else
:
self
.
gitReset
(
'%s/%s'
%
(
self
.
gitReset
(
'%s/%s'
%
(
GIT_DEFAULT_REMOTE_NAME
,
GIT_DEFAULT_BRANCH_NAME
))
GIT_DEFAULT_REMOTE_NAME
,
GIT_DEFAULT_BRANCH_NAME
))
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