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
9734e300
Commit
9734e300
authored
Jan 16, 2019
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes a/q to review
parent
f61b1e5a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
25 deletions
+26
-25
slapos/recipe/build/tests.py
slapos/recipe/build/tests.py
+26
-25
No files found.
slapos/recipe/build/tests.py
View file @
9734e300
...
...
@@ -40,25 +40,25 @@ class GitCloneNonInformativeTests(unittest.TestCase):
submodule repo and create small commits as well as links the 2 repos.
"""
# Add files in both main as well as submodule repo
check_call
(
'mkdir main_repo'
,
cwd
=
self
.
dir
,
shell
=
True
)
check_call
(
'mkdir submodule_repo'
,
cwd
=
self
.
dir
,
shell
=
True
)
os
.
mkdir
(
os
.
path
.
join
(
self
.
dir
,
'main_repo'
)
)
os
.
mkdir
(
os
.
path
.
join
(
self
.
dir
,
'submodule_repo'
)
)
self
.
project_dir
=
os
.
path
.
join
(
self
.
dir
,
'main_repo'
)
self
.
submodule_dir
=
os
.
path
.
join
(
self
.
dir
,
'submodule_repo'
,
)
self
.
submodule_dir
=
os
.
path
.
join
(
self
.
dir
,
'submodule_repo'
)
# Add files in submodule repo and initialize git in it
check_call
(
'cd submodule_repo'
,
cwd
=
self
.
dir
,
shell
=
True
)
check_call
(
'git init'
,
cwd
=
self
.
submodule_dir
,
shell
=
True
)
check_call
(
[
'git'
,
'init'
],
cwd
=
self
.
submodule_dir
)
self
.
setUpGitConfig
(
self
.
submodule_dir
)
check_call
(
'touch file1.py'
,
cwd
=
self
.
submodule_dir
,
shell
=
True
)
self
.
touch
(
self
.
submodule_dir
,
'file1.py'
)
self
.
gitAdd
(
self
.
submodule_dir
)
self
.
gitCommit
(
self
.
submodule_dir
,
msg
=
'Add file1 in submodule repo'
)
# Add files and folder in main repo and initialize git in it
check_call
(
'cd main_repo'
,
cwd
=
self
.
dir
,
shell
=
True
)
check_call
(
'git init'
,
cwd
=
self
.
project_dir
,
shell
=
True
)
check_call
(
[
'git'
,
'init'
],
cwd
=
self
.
project_dir
)
self
.
setUpGitConfig
(
self
.
project_dir
)
check_call
(
'mkdir dir1'
,
cwd
=
self
.
project_dir
,
shell
=
True
)
check_call
(
'touch file1.py'
,
cwd
=
self
.
project_dir
,
shell
=
True
)
os
.
mkdir
(
os
.
path
.
join
(
self
.
project_dir
,
'dir1'
)
)
self
.
touch
(
self
.
project_dir
,
'file1.py'
)
self
.
gitAdd
(
self
.
project_dir
)
self
.
gitCommit
(
self
.
project_dir
,
msg
=
'Add file and folder in main repo'
)
...
...
@@ -97,7 +97,7 @@ class GitCloneNonInformativeTests(unittest.TestCase):
"""
cmd
=
'git add '
+
'-u'
if
update
else
'.'
try
:
check_call
(
'git add .'
,
cwd
=
proj_dir
,
shell
=
True
)
check_call
([
'git'
,
'add'
,
'.'
],
cwd
=
proj_dir
)
except
CalledProcessError
as
e
:
logging
.
error
(
"'git add .' failed with '%s'"
%
e
.
returncode
)
...
...
@@ -117,13 +117,15 @@ class GitCloneNonInformativeTests(unittest.TestCase):
Returns the sha of HEAD of a git repo
"""
try
:
output
=
check_output
(
'git rev-parse HEAD'
,
cwd
=
proj_dir
,
shell
=
True
).
decode
(
"utf-8"
)
output
=
check_output
([
'git'
,
'rev-parse'
,
'HEAD'
],
cwd
=
proj_dir
).
decode
(
"utf-8"
)
return
output
.
rstrip
()
except
CalledProcessError
:
logging
.
error
(
"failed to call 'git rev-parse'"
)
return
None
def
touch
(
self
,
*
parts
):
os
.
close
(
os
.
open
(
os
.
path
.
join
(
*
parts
),
os
.
O_CREAT
,
0o666
))
def
makeGitCloneRecipe
(
self
,
options
):
from
slapos.recipe.gitclone
import
Recipe
bo
=
{
...
...
@@ -205,10 +207,10 @@ class GitCloneNonInformativeTests(unittest.TestCase):
submodule_repo_path
)
# Update submodule repository and main repo separately
check_call
(
'touch file2.py'
,
cwd
=
self
.
project_dir
,
shell
=
True
)
self
.
touch
(
self
.
project_dir
,
'file2.py'
)
self
.
gitAdd
(
self
.
project_dir
)
self
.
gitCommit
(
self
.
project_dir
,
msg
=
'Add file2 in main repo'
)
check_call
(
'touch file2.py'
,
cwd
=
self
.
submodule_dir
,
shell
=
True
)
self
.
touch
(
self
.
submodule_dir
,
'file2.py'
)
self
.
gitAdd
(
self
.
submodule_dir
)
self
.
gitCommit
(
self
.
submodule_dir
,
msg
=
'Add file2 in submodule repo'
)
...
...
@@ -221,7 +223,6 @@ 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
...
...
@@ -233,12 +234,12 @@ class GitCloneNonInformativeTests(unittest.TestCase):
# Update main repo with changes of submodule
submodule_dir_main_repo
=
os
.
path
.
join
(
self
.
project_dir
,
'dir1'
,
'submodule_repo'
)
check_call
(
'git checkout master'
,
cwd
=
submodule_dir_main_repo
,
shell
=
True
)
check_call
(
'git pull'
,
cwd
=
submodule_dir_main_repo
,
shell
=
True
)
check_call
(
[
'git'
,
'checkout'
,
'master'
],
cwd
=
submodule_dir_main_repo
)
check_call
(
[
'git'
,
'pull'
,
'--ff'
],
cwd
=
submodule_dir_main_repo
)
self
.
gitAdd
(
self
.
project_dir
)
self
.
gitCommit
(
self
.
project_dir
,
msg
=
'Update submodule version'
)
# STEP II: Clone repositories in status M3 and S2 (M3---->S2)
# STEP II
I
: Clone repositories in status M3 and S2 (M3---->S2)
# Update the recipe with new revision which points to submodule new revision
recipe
=
self
.
makeGitCloneRecipe
(
{
...
...
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