Skip to content

Commit 495434e

Browse files
committed
Dummy
1 parent aa9a9ff commit 495434e

File tree

2 files changed

+51
-22
lines changed

2 files changed

+51
-22
lines changed

lib/app/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414

1515
class AppManager:
1616

17+
APP_NAME: str = "Taskup"
1718
VERSION: str = "1.1.14"
1819
SHUTDOWN_DELAY = 3 # seconds
1920
SHUTDOWN_DELAY_IN_DEBUG_MODE = 600 # seconds
2021

2122
def __init__(self):
22-
Logger.log_info(msg="app init...", is_verbose=True)
23+
Logger.log_info(msg=f"{self.APP_NAME} init...", is_verbose=True)
2324

2425
# instance settings manager to take project configuration settings
2526
Logger.log_info(msg="take settings...", is_verbose=True)

lib/repo/repo.py

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from lib.utils.mixin.dcparser import DCToDictMixin
99
from lib.utils.utils import Utils
1010
from pprint import pprint
11-
from time import time
11+
from time import perf_counter
12+
from lib.app.app import AppManager
1213

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

264265
return root_node
265266

267+
def get_branches(self) -> List:
268+
"""
269+
Return list of branches
270+
271+
:return:
272+
"""
273+
274+
try:
275+
self.repo.git.fetch() # try to sync local repo with remote branches
276+
except Exception as e:
277+
Logger.log_warning(msg=f"unable to fetch commits from remote branches", is_verbose=self.verbose)
278+
279+
branches: List = []
280+
281+
# get references of local and remote branches
282+
try:
283+
branches = list(self.repo.branches) # local
284+
except Exception as e:
285+
pass
286+
287+
if self.repo.remotes:
288+
try:
289+
branches.extend(self.repo.remote().refs) # remote
290+
except Exception as e:
291+
pass
292+
293+
return branches
294+
266295
def get_commits(self) -> List[RepoNode] | None:
267296
"""
268297
Return list of project's repository commits
@@ -282,11 +311,6 @@ def get_commits(self) -> List[RepoNode] | None:
282311
Logger.log_info(msg=f"start to fetch commits from project repo '{self.project_path}'...",
283312
is_verbose=self.verbose)
284313

285-
try:
286-
self.repo.git.fetch() # try to sync local repo with remote branches
287-
except Exception as e:
288-
Logger.log_warning(msg=f"unable to fetch commits from remote branches", is_verbose=self.verbose)
289-
290314
# take tags of repo
291315
global associations_commits_tags
292316
associations_commits_tags = dict() # hexsha - tag's name
@@ -295,19 +319,7 @@ def get_commits(self) -> List[RepoNode] | None:
295319

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

298-
branches: List = []
299-
300-
# get references of local and remote branches
301-
try:
302-
branches = list(self.repo.branches) # local
303-
except Exception as e:
304-
pass
305-
306-
if self.repo.remotes:
307-
try:
308-
branches.extend(self.repo.remote().refs) # remote
309-
except Exception as e:
310-
pass
322+
branches: List = self.get_branches()
311323

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

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

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

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

356368
except Exception as e:
357369
Logger.log_error(msg=f"an error occurs during commits elaborating", is_verbose=self.verbose)
370+
371+
def create_app_branch(self) -> bool:
372+
"""
373+
Create app branch in the project
374+
375+
:return:
376+
"""
377+
378+
return NotImplementedError
379+
380+
# if not self.valid_opened_repo():
381+
# Logger.log_error(msg="impossible to create branch: repo not found", is_verbose=self.verbose)
382+
# return False
383+
#
384+
# APP_BRANCH_NAME = AppManager.APP_NAME
385+

0 commit comments

Comments
 (0)