Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
klaus
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
jonashaag
klaus
Commits
a6d322a7
Unverified
Commit
a6d322a7
authored
2 years ago
by
Jelmer Vernooij
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Handle SymrefLoop (#295)
Handle SymrefLoop. Fixes: #293
parent
32fef542
Branches
codeql
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
klaus/repo.py
+17
-5
17 additions, 5 deletions
klaus/repo.py
klaus/views.py
+10
-0
10 additions, 0 deletions
klaus/views.py
with
27 additions
and
5 deletions
klaus/repo.py
+
17
−
5
View file @
a6d322a7
...
...
@@ -9,6 +9,14 @@ from dulwich.objects import Blob
from
dulwich.errors
import
NotTreeError
import
dulwich
,
dulwich
.
patch
try
:
from
dulwich.refs
import
SymrefLoop
except
ImportError
:
# dulwich < 0.20.46
InaccessibleRef
=
KeyError
else
:
InaccessibleRef
=
(
SymrefLoop
,
KeyError
)
from
klaus.utils
import
(
force_unicode
,
parent_directory
,
...
...
@@ -134,11 +142,15 @@ class FancyRepo(dulwich.repo.Repo):
try
:
self
.
get_commit
(
candidate
)
return
candidate
except
KeyError
:
except
InaccessibleRef
:
pass
try
:
return
self
.
get_branch_names
()[
0
]
except
IndexError
:
for
name
in
self
.
get_branch_names
():
try
:
self
.
get_commit
(
name
)
return
name
except
InaccessibleRef
:
pass
else
:
return
None
def
get_ref_names_ordered_by_last_commit
(
self
,
prefix
,
exclude
=
None
):
...
...
@@ -149,7 +161,7 @@ class FancyRepo(dulwich.repo.Repo):
def
get_commit_time
(
refname
):
try
:
obj
=
self
[
refs
[
refname
]]
except
KeyError
:
except
InaccessibleRef
:
# Default to 0, i.e. sorting refs that point at non-existant
# objects last.
return
0
...
...
This diff is collapsed.
Click to expand it.
klaus/views.py
+
10
−
0
View file @
a6d322a7
...
...
@@ -13,6 +13,12 @@ import dulwich.archive
import
dulwich.config
from
dulwich.object_store
import
tree_lookup_path
try
:
from
dulwich.refs
import
SymrefLoop
except
ImportError
:
# dulwich < 0.20.46
class
SymrefLoop
(
Exception
):
"""
Dummy exception.
"""
try
:
import
ctags
except
ImportError
:
...
...
@@ -114,6 +120,10 @@ def _get_repo_and_rev(repo, namespace=None, rev=None, path=None):
rev
=
rev
[:
i
]
except
(
KeyError
,
IOError
):
i
=
rev
.
rfind
(
"
/
"
,
0
,
i
)
except
SymrefLoop
as
e
:
raise
NotFound
(
"
symref loop for %s at depth %d
"
%
(
e
.
ref
,
e
.
depth
))
else
:
break
else
:
...
...
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