Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
hgitaly
Commits
949fcc78ceee
Commit
949fcc78
authored
Mar 16, 2021
by
Sushil Khanchi
🐨
Browse files
CommitService.ListFiles: add gitaly comparison tests
parent
681f5ef1f8ce
Pipeline
#20311
passed with stages
in 2 minutes and 17 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
tests_with_gitaly/test_commit.py
View file @
949fcc78
...
...
@@ -8,6 +8,7 @@
import
pytest
import
re
from
hgitaly.stub.commit_pb2
import
(
ListFilesRequest
,
ListLastCommitsForTreeRequest
,
RawBlameRequest
,
)
...
...
@@ -190,3 +191,62 @@
do_rpc
(
'git'
,
ctx1
.
hex
(),
b
''
)
assert
exc_info_hg
.
value
.
code
()
==
exc_info_git
.
value
.
code
()
assert
exc_info_hg
.
value
.
details
()
==
exc_info_git
.
value
.
details
()
def
test_compare_list_files
(
gitaly_comparison
):
fixture
=
gitaly_comparison
repo_message
=
fixture
.
gitaly_repo
git_repo
=
fixture
.
git_repo
wrapper
=
fixture
.
hg_repo_wrapper
ctx0
=
wrapper
.
write_commit
(
'foo'
,
message
=
"Some foo"
)
git_shas
=
{
ctx0
.
hex
():
git_repo
.
branches
()[
b
'branch/default'
][
'sha'
],
}
sub
=
(
wrapper
.
path
/
'sub'
)
sub
.
mkdir
()
subdir
=
(
sub
/
'dir'
)
subdir
.
mkdir
()
(
sub
/
'bar'
).
write_text
(
'bar content'
)
(
sub
/
'ba2'
).
write_text
(
'ba2 content'
)
(
subdir
/
'bar'
).
write_text
(
'bar content'
)
(
subdir
/
'ba2'
).
write_text
(
'ba2 content'
)
# TODO OS indep for paths (actually TODO make wrapper.commit easier to
# use, e.g., check how to make it accept patterns)
ctx1
=
wrapper
.
commit
(
rel_paths
=
[
'sub/bar'
,
'sub/ba2'
,
'sub/dir/bar'
,
'sub/dir/ba2'
],
message
=
"zebar"
,
add_remove
=
True
)
git_shas
[
ctx1
.
hex
()]
=
git_repo
.
branches
()[
b
'branch/default'
][
'sha'
]
ctx2
=
wrapper
.
write_commit
(
'sub/bar'
,
message
=
'default head'
)
ctx3
=
wrapper
.
write_commit
(
'zoo'
,
parent
=
ctx0
,
branch
=
'other'
,
message
=
'other head'
)
# mirror worked
git_branches
=
git_repo
.
branches
()
assert
set
(
git_branches
)
==
{
b
'branch/default'
,
b
'branch/other'
}
# TODO check if we can access the hg-git map, would be easier
git_shas
[
ctx2
.
hex
()]
=
git_branches
[
b
'branch/default'
][
'sha'
]
git_shas
[
ctx3
.
hex
()]
=
git_branches
[
b
'branch/other'
][
'sha'
]
commit_stubs
=
dict
(
git
=
CommitServiceStub
(
fixture
.
gitaly_channel
),
hg
=
CommitServiceStub
(
fixture
.
hgitaly_channel
))
def
do_rpc
(
vcs
,
rev
):
if
vcs
==
'git'
and
len
(
rev
)
==
40
:
# defaulting useful for tests of unknown revs
rev
=
git_shas
.
get
(
rev
,
rev
)
request
=
ListFilesRequest
(
repository
=
repo_message
,
revision
=
rev
)
response
=
commit_stubs
[
vcs
].
ListFiles
(
request
)
final
=
[]
for
resp
in
response
:
final
.
extend
(
resp
.
paths
)
return
final
not_exists
=
b
'65face65'
*
5
for
rev
in
[
ctx0
.
hex
(),
ctx1
.
hex
(),
ctx2
.
hex
(),
ctx3
.
hex
(),
not_exists
,
b
'branch/default'
,
b
'branch/other'
]:
assert
do_rpc
(
'hg'
,
rev
)
==
do_rpc
(
'git'
,
rev
)
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