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
Gepetto
dashboard
Commits
2d4016fc
Commit
2d4016fc
authored
Feb 24, 2020
by
Guilhem Saurel
Browse files
delete branch
parent
50e7562e
Pipeline
#8472
failed with stage
in 34 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
gh/views.py
View file @
2d4016fc
...
...
@@ -14,7 +14,7 @@ from django.shortcuts import get_object_or_404
from
django.utils.encoding
import
force_bytes
from
django.views.decorators.csrf
import
csrf_exempt
from
rainboard.models
import
Namespace
,
Project
from
rainboard.models
import
Forge
,
Namespace
,
Project
from
.
import
models
...
...
@@ -48,6 +48,15 @@ def push(request: HttpRequest, rep: str) -> HttpResponse:
gh_remote
=
git_repo
.
remotes
[
gh_remote_s
]
gh_remote
.
fetch
()
gh_ref
=
gh_remote
.
refs
[
ref_s
]
if
data
[
'arter'
]
==
"0000000000000000000000000000000000000000"
:
print
(
"branch deleted"
)
git_repo
.
delete_head
([
gh_ref_s
,
gl_ref_s
,
ref_s
],
force
=
True
)
gitlab
=
Forge
.
objects
.
get
(
slug
=
'gitlab'
)
project_u
=
f
'
{
namespace
.
slug
}
/
{
project
.
slug
}
'
.
replace
(
'/'
,
'%2F'
)
branch_u
=
ref_s
.
replace
(
'/'
,
'%2F'
)
url
=
f
'/projects/
{
project_u
}
/repository/branches/
{
branch_u
}
'
requests
.
delete
(
gitlab
.
api_url
()
+
url
,
verify
=
gitlab
.
verify
,
headers
=
gitlab
.
headers
())
if
str
(
gh_ref
.
commit
)
!=
data
[
'after'
]:
fail
=
f
'push: wrong commit:
{
gh_ref
.
commit
}
vs
{
data
[
"after"
]
}
'
print
(
fail
)
...
...
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