Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
py-heptapod
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
py-heptapod
Commits
29456f16
Commit
29456f16
authored
4 years ago
by
Raphaël Gomès
Browse files
Options
Downloads
Patches
Plain Diff
git: escape invalid Git refs that are still valid topic names
parent
9699ccac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!41
git: escape invalid Git refs that are still valid topic names
Pipeline
#13815
passed
4 years ago
Stage: main
Stage: compat
Stage: downstream
Pipeline: hgitaly
#13816
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hgext3rd/heptapod/git.py
+8
-0
8 additions, 0 deletions
hgext3rd/heptapod/git.py
hgext3rd/heptapod/tests/git/test_integration.py
+20
-0
20 additions, 0 deletions
hgext3rd/heptapod/tests/git/test_integration.py
with
28 additions
and
0 deletions
hgext3rd/heptapod/git.py
+
8
−
0
View file @
29456f16
...
...
@@ -55,6 +55,8 @@
from
.
import
obsutil
from
.branch
import
set_default_gitlab_branch
DOT_BYTE
=
ord
(
b
'
.
'
)
class
MultipleDescendants
(
LookupError
):
pass
...
...
@@ -921,6 +923,12 @@
topbranch
=
topbranch
.
replace
(
b
'
'
,
b
'
_
'
)
if
b
'
:
'
in
topbranch
:
branch
,
topic
=
topbranch
.
split
(
b
'
:
'
,
1
)
topic
=
topic
.
replace
(
b
'
.lock
'
,
b
'
_lock
'
)
if
topic
[
0
]
==
DOT_BYTE
:
topic
=
b
'
_
'
+
topic
[
1
:]
if
topic
[
-
1
]
==
DOT_BYTE
:
topic
=
topic
[:
-
1
]
+
b
'
_
'
if
b
'
/
'
in
topic
:
msg
=
b
"
Invalid character
'
/
'
in topic name %r.
"
%
topic
if
self
.
ui
.
configbool
(
b
'
experimental
'
,
...
...
This diff is collapsed.
Click to expand it.
hgext3rd/heptapod/tests/git/test_integration.py
+
20
−
0
View file @
29456f16
...
...
@@ -803,6 +803,26 @@
(
'
post-receive
'
,
(
prune_reasons
,
changes
))]
def
test_topic_git_escape
(
tmpdir
,
monkeypatch
):
notifs
=
[]
patch_gitlab_hooks
(
monkeypatch
,
notifs
)
wrapper
,
_
=
make_main_repo
(
tmpdir
.
join
(
'
repo.hg
'
))
del
notifs
[:]
# Only test names that are possible with topics in the first place
invalid_git_ref_names
=
[
"
.starts-with-dot
"
,
"
..
"
,
"
ends-with.lock
"
,
"
ends-with-dot.
"
,
]
for
name
in
invalid_git_ref_names
:
wrapper
.
write_commit
(
'
zz
'
,
message
=
'
in topic
'
,
topic
=
name
)
# This fails if topic names that are invalid in Git are not escaped
wrapper
.
command
(
'
gitlab-mirror
'
)
def
test_topic_add_rebase_publish
(
tmpdir
,
monkeypatch
):
notifs
=
[]
patch_gitlab_hooks
(
monkeypatch
,
notifs
)
...
...
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