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
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.recipe.build
Commits
b1ee7390
Commit
b1ee7390
authored
Jan 15, 2019
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update submodules
parent
8ff4bce7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
+20
-16
slapos/recipe/build/tests.py
slapos/recipe/build/tests.py
+6
-5
slapos/recipe/gitclone.py
slapos/recipe/gitclone.py
+14
-11
No files found.
slapos/recipe/build/tests.py
View file @
b1ee7390
...
...
@@ -105,25 +105,25 @@ class GitCloneNonInformativeTests(unittest.TestCase):
subprocess
.
check_call
(
'git add .'
,
cwd
=
proj_dir
,
shell
=
True
)
except
subprocess
.
CalledProcessError
as
e
:
# XXX: This is ugly and old. Change it before review
logging
.
error
(
"'git add .' failed with '
{}'"
.
format
(
e
.
returncode
)
)
logging
.
error
(
"'git add .' failed with '
%s'"
%
e
.
returncode
)
def
gitCommit
(
self
,
proj_dir
,
msg
):
"""runs a 'git commit -m msg' in the provided git repo
:param proj_dir: path to a git repo
"""
try
:
subprocess
.
check_call
(
'git commit -m "
{}"'
.
format
(
msg
)
,
subprocess
.
check_call
(
'git commit -m "
%s"'
%
msg
,
cwd
=
proj_dir
,
shell
=
True
)
except
subprocess
.
CalledProcessError
as
e
:
logging
.
error
(
"'git commit' failed with '
{}'"
.
format
(
e
.
returncode
)
)
logging
.
error
(
"'git commit' failed with '
%s'"
%
e
.
returncode
)
def
getRepositoryHeadCommit
(
self
,
proj_dir
,
branch
=
'master'
):
def
getRepositoryHeadCommit
(
self
,
proj_dir
):
"""
Returns the sha of HEAD of a git repo
"""
try
:
output
=
subprocess
.
check_output
(
'git rev-parse
{}'
.
format
(
branch
)
,
output
=
subprocess
.
check_output
(
'git rev-parse
HEAD'
,
cwd
=
proj_dir
,
shell
=
True
).
decode
(
"utf-8"
)
return
output
.
rstrip
()
except
subprocess
.
CalledProcessError
:
...
...
@@ -227,6 +227,7 @@ class GitCloneNonInformativeTests(unittest.TestCase):
'revision'
:
str
(
self
.
getRepositoryHeadCommit
(
self
.
project_dir
))
}
)
#import pdb; pdb.set_trace()
recipe
.
update
()
self
.
assertTrue
(
os
.
path
.
exists
(
main_repo_path
))
# Check if the submodule is not empty
...
...
slapos/recipe/gitclone.py
View file @
b1ee7390
...
...
@@ -273,6 +273,9 @@ class Recipe(object):
Do a git fetch.
If user doesn't develop, reset to remote revision (or branch if revision is
not specified).
With support for submodules, we also update the submodule repository if
there has been update to the pointer of the submodules in the parent repo.
This however puts the updated submodules in a DETACHED state.
"""
try
:
# first cleanup pyc files
...
...
@@ -289,22 +292,22 @@ class Recipe(object):
if
not
revision_already_fetched
:
# With --recurse-submodules, it will fetch the updated branches of the
# submodules as well as of the main repo. It will remain in a detached
# head old state
# NOTE: It won't checkout to the updated master/main-branch
# submodules as well as of the main repo.
check_call
([
self
.
git_command
,
'fetch'
,
'--recurse-submodules'
,
'--all'
],
cwd
=
self
.
location
)
# Also update the submodule directory
# If develop parameter is set, don't reset/update.
# Otherwise, reset --hard
if
not
self
.
develop
:
if
self
.
revision
:
self
.
gitReset
(
self
.
revision
)
else
:
self
.
gitReset
(
'@{upstream}'
)
# Also update the submodule directory to the commit which parent
# repository is pointing to.
# NOTE: This will put the submodule repo in a `Detached` state.
check_call
([
self
.
git_command
,
'submodule'
,
'update'
,
'--recursive'
],
cwd
=
self
.
location
)
# If develop parameter is set, don't reset/update.
# Otherwise, reset --hard
if
not
self
.
develop
:
if
self
.
revision
:
self
.
gitReset
(
self
.
revision
)
else
:
self
.
gitReset
(
'@{upstream}'
)
except
:
if
not
self
.
develop
:
...
...
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