Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gitreceive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ansible
gitreceive
Commits
1e1f9009
Commit
1e1f9009
authored
8 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
- A more realistic receiver script, added tests to verify said script.
parent
cf9cd46b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/files/receiver.sh
+36
-2
36 additions, 2 deletions
tests/files/receiver.sh
tests/playbook.yml
+9
-1
9 additions, 1 deletion
tests/playbook.yml
tests/test_gitreceive.py
+6
-3
6 additions, 3 deletions
tests/test_gitreceive.py
with
51 additions
and
6 deletions
tests/files/receiver.sh
+
36
−
2
View file @
1e1f9009
#!/bin/sh
#!/bin/sh
set
-eu
set
-eu
# This part was copied verbatim from
# https://github.com/progrium/gitreceive/wiki/TipsAndTricks
fetch_submodules
()
{
# We reinitialize .git to avoid conflicts
rm
-fr
.git
# GIT_DIR is previously set by gitreceive to ".", we want it back to default
# for this
unset
GIT_DIR
git init
.
# We read the submodules from .gitmodules
git config
-f
.gitmodules
--get-regexp
'^submodule\..*\.path$'
|
while
read
path_key path
do
rm
-fr
$path
url_key
=
`
echo
$path_key
|
sed
's/\.path/.url/'
`
url
=
`
git config
-f
.gitmodules
--get
"
$url_key
"
`
git submodule add
$url
$path
done
}
mkdir
-p
/var/tmp/gitreceive
mkdir
-p
/var/tmp/gitreceive
tar
-xC
/var/tmp/gitreceive
-f
-
cd
/var/tmp/gitreceive
echo
"OK"
echo
'----> Unpacking ...'
tar
-xf
-
if
[
-f
.gitmodules
]
then
echo
'----> Fetching submodules ...'
fetch_submodules
fi
if
[
-f
receiver
]
&&
[
-x
receiver
]
then
echo
'----> Running receiver ...'
./receiver
fi
echo
'----> OK.'
This diff is collapsed.
Click to expand it.
tests/playbook.yml
+
9
−
1
View file @
1e1f9009
...
@@ -59,9 +59,17 @@
...
@@ -59,9 +59,17 @@
args
:
args
:
creates
:
/root/.ssh/known_hosts
creates
:
/root/.ssh/known_hosts
-
name
:
Clone gitreceive test repo
git
:
dest
:
/root/gitreceive-test
force
:
yes
update
:
yes
repo
:
https://www.shore.co.il/git/gitreceive-test
version
:
master
-
name
:
Add localhost as a git remote
-
name
:
Add localhost as a git remote
blockinfile
:
blockinfile
:
dest
:
/root/gitreceive/.git/config
dest
:
/root/gitreceive
-test
/.git/config
block
:
|
block
:
|
[remote "test"]
[remote "test"]
url = git@localhost:test
url = git@localhost:test
...
...
This diff is collapsed.
Click to expand it.
tests/test_gitreceive.py
+
6
−
3
View file @
1e1f9009
...
@@ -6,10 +6,13 @@ testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
...
@@ -6,10 +6,13 @@ testinfra_hosts = AnsibleRunner('.molecule/ansible_inventory').get_hosts('all')
def
test_gitreceive
(
Command
,
Sudo
):
def
test_gitreceive
(
Command
,
Sudo
):
with
Sudo
():
with
Sudo
():
Command
(
'
rm -rf /home/git/test /var/tmp/gitreceive
'
)
Command
(
'
rm -rf /home/git/test /var/tmp/gitreceive
'
)
push
=
Command
(
'
git -C /root/gitreceive push test master
'
)
push
=
Command
(
'
git -C /root/gitreceive
-test
push test master
'
)
assert
push
.
rc
==
0
assert
push
.
rc
==
0
assert
'
OK
'
in
push
.
stderr
for
message
in
[
'
----> Unpacking ...
'
,
'
----> Fetching submodules ...
'
,
'
----> Running receiver ...
'
,
'
Dummy receiver script
'
,
'
----> OK.
'
]:
assert
message
in
push
.
stderr
with
Sudo
():
with
Sudo
():
second_push
=
Command
(
'
git -C /root/gitreceive push test master
'
)
second_push
=
Command
(
'
git -C /root/gitreceive
-test
push test master
'
)
assert
second_push
.
rc
==
0
assert
second_push
.
rc
==
0
assert
'
Everything up-to-date
'
in
second_push
.
stderr
assert
'
Everything up-to-date
'
in
second_push
.
stderr
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment