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
89d5c94a
Commit
89d5c94a
authored
4 years ago
by
Georges Racinet
Browse files
Options
Downloads
Patches
Plain Diff
Clarity refactor and line lengths in tests
(were actually uncommitted local mods)
parent
83f11149
No related branches found
No related tags found
No related merge requests found
Pipeline
#6174
passed
4 years ago
Stage: main
Stage: compat
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hgext3rd/heptapod/git.py
+19
-5
19 additions, 5 deletions
hgext3rd/heptapod/git.py
hgext3rd/heptapod/tests/git/test_integration.py
+5
-2
5 additions, 2 deletions
hgext3rd/heptapod/tests/git/test_integration.py
with
24 additions
and
7 deletions
hgext3rd/heptapod/git.py
+
19
−
5
View file @
89d5c94a
...
...
@@ -40,6 +40,19 @@
return
'
refs/heads/
'
+
branch
TOPIC_REF_PREFIX
=
git_branch_ref
(
'
topic/
'
)
NAMED_BRANCH_REF_PREFIX
=
git_branch_ref
(
'
branch/
'
)
def
ref_is_topic
(
ref
):
return
ref
.
startswith
(
TOPIC_REF_PREFIX
)
def
ref_is_named_branch
(
ref
):
return
ref
.
startswith
(
NAMED_BRANCH_REF_PREFIX
)
def
parse_git_branch_ref
(
ref
):
"""
Parse a Git branch ref for named branch and topic information
...
...
@@ -109,6 +122,9 @@
self
.
before
=
before
self
.
after
=
after
def
is_creation
(
self
):
return
self
.
before
==
ZERO_SHA
and
self
.
after
!=
ZERO_SHA
class
HeptapodGitHandler
(
GitHandler
):
...
...
@@ -524,12 +540,11 @@
# a random value - we don't want it to select topics if possible
# and if it has, we want that to change.
default_branch_ref
=
self
.
git
.
refs
.
get_symrefs
().
get
(
b
'
HEAD
'
)
update_default_branch
=
(
default_branch_ref
not
in
git_refs
or
default_branch_ref
.
startswith
(
git_branch_ref
(
b
'
topic/
'
)))
update_default_branch
=
(
default_branch_ref
not
in
git_refs
or
ref_is_topic
(
default_branch_ref
))
new_named_branch_refs
=
[]
for
change
in
pycompat
.
itervalues
(
changes
):
if
change
.
after
==
ZERO_SHA
:
del
git_refs
[
change
.
ref
]
else
:
git_refs
[
change
.
ref
]
=
change
.
after
...
...
@@ -530,11 +545,10 @@
new_named_branch_refs
=
[]
for
change
in
pycompat
.
itervalues
(
changes
):
if
change
.
after
==
ZERO_SHA
:
del
git_refs
[
change
.
ref
]
else
:
git_refs
[
change
.
ref
]
=
change
.
after
if
(
change
.
before
==
ZERO_SHA
and
change
.
ref
.
startswith
(
git_branch_ref
(
b
'
branch/
'
))):
if
change
.
is_creation
()
and
ref_is_named_branch
(
change
.
ref
):
new_named_branch_refs
.
append
(
change
.
ref
)
if
update_default_branch
and
new_named_branch_refs
:
...
...
This diff is collapsed.
Click to expand it.
hgext3rd/heptapod/tests/git/test_integration.py
+
5
−
2
View file @
89d5c94a
...
...
@@ -252,7 +252,8 @@
# just checking our assumptions
assert
git_repo
.
branch_titles
()
==
{
'
branch/default
'
:
'
default1
'
}
# we need to test the branch masking on a branch that's not the GitLab default
# we need to test the branch masking on a branch
# that's not the GitLab default (which is protected)
server
.
write_commit
(
'
foo
'
,
branch
=
'
other
'
,
message
=
'
other1
'
)
activate_mirror
(
server
)
...
...
@@ -283,7 +284,9 @@
wrapper
=
LocalRepoWrapper
.
init
(
tmpdir
.
join
(
'
repo.hg
'
),
config
=
config
)
git_repo
=
GitRepo
.
init
(
tmpdir
.
join
(
'
repo.git
'
))
wrapper
.
write_commit
(
'
foo
'
,
message
=
"
other0
"
,
branch
=
branch_name
,
topic
=
'
initial
'
)
wrapper
.
write_commit
(
'
foo
'
,
message
=
"
other0
"
,
branch
=
branch_name
,
topic
=
'
initial
'
)
wrapper
.
command
(
'
gitlab-mirror
'
)
# that's what something (maybe Gitaly) does on the GitLab side:
git_repo
.
set_symref
(
'
HEAD
'
,
'
refs/heads/topic/%s/initial
'
%
branch_name
)
...
...
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