Addon Manager: Refactor Licenses and People tables
This commit is contained in:
@@ -120,7 +120,9 @@ class GitManager:
|
||||
+ "...\n"
|
||||
)
|
||||
remote = self.get_remote(local_path)
|
||||
with open(os.path.join(local_path, "ADDON_DISABLED"), "w", encoding="utf-8") as f:
|
||||
with open(
|
||||
os.path.join(local_path, "ADDON_DISABLED"), "w", encoding="utf-8"
|
||||
) as f:
|
||||
f.write(
|
||||
"This is a backup of an addon that failed to update cleanly so was re-cloned. "
|
||||
+ "It was disabled by the Addon Manager's git update facility and can be "
|
||||
@@ -195,7 +197,9 @@ class GitManager:
|
||||
# branch = self._synchronous_call_git(["branch", "--show-current"]).strip()
|
||||
|
||||
# This is more universal (albeit more opaque to the reader):
|
||||
branch = self._synchronous_call_git(["rev-parse", "--abbrev-ref", "HEAD"]).strip()
|
||||
branch = self._synchronous_call_git(
|
||||
["rev-parse", "--abbrev-ref", "HEAD"]
|
||||
).strip()
|
||||
except GitFailed as e:
|
||||
os.chdir(old_dir)
|
||||
raise e
|
||||
@@ -257,11 +261,13 @@ class GitManager:
|
||||
return result
|
||||
|
||||
def get_branches(self, local_path) -> List[str]:
|
||||
""" Get a list of all available branches (local and remote) """
|
||||
"""Get a list of all available branches (local and remote)"""
|
||||
old_dir = os.getcwd()
|
||||
os.chdir(local_path)
|
||||
try:
|
||||
stdout = self._synchronous_call_git(["branch", "-a", "--format=%(refname:lstrip=2)"])
|
||||
stdout = self._synchronous_call_git(
|
||||
["branch", "-a", "--format=%(refname:lstrip=2)"]
|
||||
)
|
||||
except GitFailed as e:
|
||||
os.chdir(old_dir)
|
||||
raise e
|
||||
@@ -272,17 +278,24 @@ class GitManager:
|
||||
return branches
|
||||
|
||||
def get_last_committers(self, local_path, n=10):
|
||||
""" Examine the last n entries of the commit history, and return a list of all of the
|
||||
committers, their email addresses, and how many commits each one is responsible for. """
|
||||
"""Examine the last n entries of the commit history, and return a list of all of the
|
||||
committers, their email addresses, and how many commits each one is responsible for."""
|
||||
old_dir = os.getcwd()
|
||||
os.chdir(local_path)
|
||||
authors = self._synchronous_call_git(["log", f"-{n}", "--format=%cN"])
|
||||
emails = self._synchronous_call_git(["log", f"-{n}", "--format=%cE"])
|
||||
authors = self._synchronous_call_git(["log", f"-{n}", "--format=%cN"]).split(
|
||||
"\n"
|
||||
)
|
||||
emails = self._synchronous_call_git(["log", f"-{n}", "--format=%cE"]).split(
|
||||
"\n"
|
||||
)
|
||||
os.chdir(old_dir)
|
||||
|
||||
result_dict = {}
|
||||
for author,email in zip(authors,emails):
|
||||
for author, email in zip(authors, emails):
|
||||
if not author or not email:
|
||||
continue
|
||||
if author not in result_dict:
|
||||
result_dict[author] = {}
|
||||
result_dict[author]["email"] = [email]
|
||||
result_dict[author]["count"] = 1
|
||||
else:
|
||||
@@ -294,8 +307,8 @@ class GitManager:
|
||||
return result_dict
|
||||
|
||||
def get_last_authors(self, local_path, n=10):
|
||||
""" Examine the last n entries of the commit history, and return a list of all of the
|
||||
authors, their email addresses, and how many commits each one is responsible for. """
|
||||
"""Examine the last n entries of the commit history, and return a list of all of the
|
||||
authors, their email addresses, and how many commits each one is responsible for."""
|
||||
old_dir = os.getcwd()
|
||||
os.chdir(local_path)
|
||||
authors = self._synchronous_call_git(["log", f"-{n}", "--format=%aN"])
|
||||
@@ -303,7 +316,7 @@ class GitManager:
|
||||
os.chdir(old_dir)
|
||||
|
||||
result_dict = {}
|
||||
for author,email in zip(authors,emails):
|
||||
for author, email in zip(authors, emails):
|
||||
if author not in result_dict:
|
||||
result_dict[author]["email"] = [email]
|
||||
result_dict[author]["count"] = 1
|
||||
@@ -348,7 +361,7 @@ class GitManager:
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=True,
|
||||
shell=True # On Windows this will prevent all the pop-up consoles
|
||||
shell=True, # On Windows this will prevent all the pop-up consoles
|
||||
)
|
||||
else:
|
||||
proc = subprocess.run(
|
||||
|
||||
Reference in New Issue
Block a user