Skip to content

Commit

Permalink
Dummy
Browse files Browse the repository at this point in the history
  • Loading branch information
nricciardi committed Jun 10, 2023
1 parent aa9a9ff commit 495434e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 22 deletions.
3 changes: 2 additions & 1 deletion lib/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@

class AppManager:

APP_NAME: str = "Taskup"
VERSION: str = "1.1.14"
SHUTDOWN_DELAY = 3 # seconds
SHUTDOWN_DELAY_IN_DEBUG_MODE = 600 # seconds

def __init__(self):
Logger.log_info(msg="app init...", is_verbose=True)
Logger.log_info(msg=f"{self.APP_NAME} init...", is_verbose=True)

# instance settings manager to take project configuration settings
Logger.log_info(msg="take settings...", is_verbose=True)
Expand Down
70 changes: 49 additions & 21 deletions lib/repo/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from lib.utils.mixin.dcparser import DCToDictMixin
from lib.utils.utils import Utils
from pprint import pprint
from time import time
from time import perf_counter
from lib.app.app import AppManager

# global variables to pass associations to RepoNode dataclass
associations_commits_tags: Dict[str, str] = dict() # hexsha - tag's name
Expand Down Expand Up @@ -263,6 +264,34 @@ def get_tree(self) -> Optional[RepoNode]:

return root_node

def get_branches(self) -> List:
"""
Return list of branches
:return:
"""

try:
self.repo.git.fetch() # try to sync local repo with remote branches
except Exception as e:
Logger.log_warning(msg=f"unable to fetch commits from remote branches", is_verbose=self.verbose)

branches: List = []

# get references of local and remote branches
try:
branches = list(self.repo.branches) # local
except Exception as e:
pass

if self.repo.remotes:
try:
branches.extend(self.repo.remote().refs) # remote
except Exception as e:
pass

return branches

def get_commits(self) -> List[RepoNode] | None:
"""
Return list of project's repository commits
Expand All @@ -282,11 +311,6 @@ def get_commits(self) -> List[RepoNode] | None:
Logger.log_info(msg=f"start to fetch commits from project repo '{self.project_path}'...",
is_verbose=self.verbose)

try:
self.repo.git.fetch() # try to sync local repo with remote branches
except Exception as e:
Logger.log_warning(msg=f"unable to fetch commits from remote branches", is_verbose=self.verbose)

# take tags of repo
global associations_commits_tags
associations_commits_tags = dict() # hexsha - tag's name
Expand All @@ -295,19 +319,7 @@ def get_commits(self) -> List[RepoNode] | None:

Logger.log_info(msg=f"fetched {len(associations_commits_tags.keys())} tags", is_verbose=self.verbose)

branches: List = []

# get references of local and remote branches
try:
branches = list(self.repo.branches) # local
except Exception as e:
pass

if self.repo.remotes:
try:
branches.extend(self.repo.remote().refs) # remote
except Exception as e:
pass
branches: List = self.get_branches()

Logger.log_info(msg=f"fetched {len(branches)} branch(es)", is_verbose=self.verbose)

Expand All @@ -329,7 +341,7 @@ def get_commits(self) -> List[RepoNode] | None:

nodes = list() # use a managed list to share data between processes
n_of_commits = len(all_repo_commits)
start = time()
start = perf_counter()
for i in range(n_of_commits):
commit = all_repo_commits[i]
repo_node: RepoNode = RepoNode.from_commit(commit)
Expand All @@ -349,9 +361,25 @@ def get_commits(self) -> List[RepoNode] | None:
msg=f"elaborating commit {i + 1}/{n_of_commits} ({round((i + 1) * 100 / n_of_commits, 2)}%)",
is_verbose=self.verbose)

Logger.log_success(msg=f"commits fetched successfully in {round(time() - start, 4)}s",
Logger.log_success(msg=f"commits fetched successfully in {round(perf_counter() - start, 4)}s",
is_verbose=self.verbose)
return list(nodes)

except Exception as e:
Logger.log_error(msg=f"an error occurs during commits elaborating", is_verbose=self.verbose)

def create_app_branch(self) -> bool:
"""
Create app branch in the project
:return:
"""

return NotImplementedError

# if not self.valid_opened_repo():
# Logger.log_error(msg="impossible to create branch: repo not found", is_verbose=self.verbose)
# return False
#
# APP_BRANCH_NAME = AppManager.APP_NAME

0 comments on commit 495434e

Please sign in to comment.