Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade pygit2 to 1.16 and fix bugs, test pass on macos 15 #132

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/git_deps/cli.py",
"console": "integratedTerminal",
"args": [
"master"
]
}
]
}
34 changes: 17 additions & 17 deletions git_deps/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ def find_dependencies(self, dependent_rev, recurse=None):
abort(e.message())

self.todo.append(dependent)
self.todo_d[dependent.hex] = True
self.todo_d[str(dependent.id)] = True

first_time = True

while self.todo:
sha1s = [commit.hex[:8] for commit in self.todo]
sha1s = [str(commit.id)[:8] for commit in self.todo]
if first_time:
self.logger.info("Initial TODO list: %s" % " ".join(sha1s))
first_time = False
else:
self.logger.info(" TODO list now: %s" % " ".join(sha1s))
dependent = self.todo.pop(0)
dependent_sha1 = dependent.hex
dependent_sha1 = str(dependent.id)
del self.todo_d[dependent_sha1]
self.logger.info(" Processing %s from TODO list" %
dependent_sha1[:8])
Expand Down Expand Up @@ -140,7 +140,7 @@ def find_dependencies_with_parent(self, dependent, parent):
merge commits which have multiple parents.
"""
self.logger.info(" Finding dependencies of %s via parent %s" %
(dependent.hex[:8], parent.hex[:8]))
(str(dependent.id)[:8], str(parent.id)[:8]))
diff = self.repo.diff(parent, dependent,
context_lines=self.options.context_lines)
for patch in diff:
Expand All @@ -159,7 +159,7 @@ def blame_diff_hunk(self, dependent, parent, path, hunk):
line_range_before = "-%d,%d" % (hunk.old_start, hunk.old_lines)
line_range_after = "+%d,%d" % (hunk.new_start, hunk.new_lines)
self.logger.info(" Blaming hunk %s @ %s (listed below)" %
(line_range_before, parent.hex[:8]))
(line_range_before, str(parent.id)[:8]))

if not self.tree_lookup(path, parent):
# This is probably because dependent added a new directory
Expand All @@ -168,7 +168,7 @@ def blame_diff_hunk(self, dependent, parent, path, hunk):

blame = self.run_blame(hunk, parent, path)

dependent_sha1 = dependent.hex
dependent_sha1 = str(dependent.id)
self.register_new_dependent(dependent, dependent_sha1)

line_to_culprit = {}
Expand All @@ -192,7 +192,7 @@ def process_blame_hunk(self, dependent, dependent_sha1, parent,

dependency = self.get_commit(dependency_sha1)
for i in range(blame_hunk.lines_in_hunk):
line_to_culprit[line_num + i] = dependency.hex
line_to_culprit[line_num + i] = str(dependency.id)

if self.is_excluded(dependency):
self.logger.debug(
Expand Down Expand Up @@ -239,12 +239,12 @@ def register_new_dependent(self, dependent, dependent_sha1):
def run_blame(self, hunk, parent, path):
if self.options.pygit2_blame:
return self.repo.blame(path,
newest_commit=parent.hex,
newest_commit=str(parent.id),
min_line=hunk.old_start,
max_line=hunk.old_start + hunk.old_lines - 1)
else:
return blame_via_subprocess(path,
parent.hex,
str(parent.id),
hunk.old_start,
hunk.old_lines)

Expand Down Expand Up @@ -285,9 +285,9 @@ def process_new_dependency(self, dependent, dependent_sha1,
if dependency_sha1 not in self.dependencies:
if self.options.recurse:
self.todo.append(dependency)
self.todo_d[dependency.hex] = True
self.todo_d[str(dependency.id)] = True
self.logger.info(" + Added %s to TODO" %
dependency.hex[:8])
str(dependency.id)[:8])

def record_dependency_source(self, parent,
dependent, dependent_sha1,
Expand All @@ -304,7 +304,7 @@ def record_dependency_source(self, parent,
abort("line %d already found when blaming %s:%s\n"
"old:\n %s\n"
"new:\n %s" %
(line_num, parent.hex[:8], path,
(line_num, str(parent.id)[:8], path,
dep_sources[path][line_num], line))

dep_sources[path][line_num] = line
Expand All @@ -314,9 +314,9 @@ def record_dependency_source(self, parent,
dependent, dependency, path, line_num)

def branch_contains(self, commit, branch):
sha1 = commit.hex
sha1 = str(commit.id)
branch_commit = self.get_commit(branch)
branch_sha1 = branch_commit.hex
branch_sha1 = str(branch_commit.id)
self.logger.debug(" Does %s (%s) contain %s?" %
(branch, branch_sha1[:8], sha1[:8]))

Expand Down Expand Up @@ -349,7 +349,7 @@ def tree_lookup(self, target_path, commit):
dirent = segments.pop(0)
if isinstance(tree_or_blob, pygit2.Tree):
if dirent in tree_or_blob:
tree_or_blob = self.repo[tree_or_blob[dirent].oid]
tree_or_blob = self.repo[tree_or_blob[dirent].id]
# self.logger.debug(" %s in %s" % (dirent, path))
if path:
path += '/'
Expand All @@ -358,11 +358,11 @@ def tree_lookup(self, target_path, commit):
# This is probably because we were called on a
# commit whose parent added a new directory.
self.logger.debug(" %s not in %s in %s" %
(dirent, path, commit.hex[:8]))
(dirent, path, str(commit.id)[:8]))
return None
else:
self.logger.debug(" %s not a tree in %s" %
(tree_or_blob, commit.hex[:8]))
(tree_or_blob, str(commit.id)[:8]))
return None
return tree_or_blob

Expand Down
4 changes: 2 additions & 2 deletions git_deps/gitutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def oneline(cls, commit):

@classmethod
def commit_summary(cls, commit):
return "%s %s" % (commit.hex[:8], cls.oneline(commit))
return "%s %s" % (str(commit.id)[:8], cls.oneline(commit))

@classmethod
def refs_to(cls, sha1, repo):
Expand All @@ -74,7 +74,7 @@ def refs_to(cls, sha1, repo):
dref = symref.resolve()
oid = dref.target
commit = repo.get(oid)
if commit.hex == sha1:
if commit.id == sha1:
matching.append(symref.shorthand)

return matching
Expand Down
2 changes: 1 addition & 1 deletion git_deps/html/git-deps.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8" />
<title>git commit dependency graph</title>

<script language="javascript" type="text/javascript" src="node_modules/d3/d3.min.js"></script>
<script language="javascript" type="text/javascript" src="js/d3.min.js"></script>
<script language="javascript" type="text/javascript" src="js/bundle.js"></script>

<link rel="stylesheet" type="text/css" href="css/animate.css" />
Expand Down
1 change: 0 additions & 1 deletion git_deps/html/js/.gitignore

This file was deleted.

Loading