Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hgitaly
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
heptapod
hgitaly
Commits
949fcc78
Commit
949fcc78
authored
4 years ago
by
Sushil Khanchi
Browse files
Options
Downloads
Patches
Plain Diff
CommitService.ListFiles: add gitaly comparison tests
parent
681f5ef1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!50
commitService: implement ListFiles
Pipeline
#20311
passed
4 years ago
Stage: main
Stage: compat
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests_with_gitaly/test_commit.py
+60
-0
60 additions, 0 deletions
tests_with_gitaly/test_commit.py
with
60 additions
and
0 deletions
tests_with_gitaly/test_commit.py
+
60
−
0
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
)
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