Skip to content

Commit

Permalink
Merge pull request #109 from sclorg/use_proper_names
Browse files Browse the repository at this point in the history
Let's use proper names as gitlab use it.
  • Loading branch information
phracek authored Aug 30, 2023
2 parents 236ae9d + 93d1668 commit dd2a525
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
12 changes: 6 additions & 6 deletions betka/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Betka(Bot):
def __init__(self, task_name=None):
super().__init__(task_name=task_name)
self.betka_tmp_dir = TemporaryDirectory()
self.clone_url: str = None
self.ssh_url_to_repo: str = None
self.betka_schema: Dict = {}
self.image = None
self.project_id: int = 0
Expand Down Expand Up @@ -340,7 +340,7 @@ def sync_to_downstream_branches(self, branch):
)
mr_id = self.gitlab_api.check_gitlab_merge_requests(branch=branch)
if not mr_id:
Git.get_changes_from_distgit(url=self.gitlab_api.clone_url)
Git.get_changes_from_distgit(url=self.gitlab_api.get_forked_ssh_url_to_repo())
Git.push_changes_to_fork(branch=branch)

if not self.sync_upstream_to_downstream_directory():
Expand Down Expand Up @@ -508,7 +508,7 @@ def prepare(self):
def prepare_downstream_git(self, project_fork: ProjectFork) -> bool:

"""
Clone downstream dist-git repository, defined by self.clone_url variable
Clone downstream dist-git repository, defined by self.ssh_url_to_repo variable
and set `self.downstream_dir` variable.
:returns True if downstream git directory was cloned
False if downstream git directory was not cloned
Expand All @@ -522,7 +522,7 @@ def prepare_downstream_git(self, project_fork: ProjectFork) -> bool:
return False
os.chdir(str(self.downstream_dir))
# This function updates fork based on the upstream
Git.get_changes_from_distgit(url=self.gitlab_api.get_upstream_clone_url())
Git.get_changes_from_distgit(url=self.gitlab_api.get_forked_ssh_url_to_repo())

return True

Expand Down Expand Up @@ -674,8 +674,8 @@ def _run_sync(self):
)
os.chdir(self.betka_tmp_dir.name)

self.clone_url = project_fork.ssh_url_to_repo
self.debug(f"Clone URL is: {self.clone_url}")
self.ssh_url_to_repo = project_fork.ssh_url_to_repo
self.debug(f"Clone URL is: {self.ssh_url_to_repo}")
# after downstream is cloned then
# new cwd is self.downstream_dir
if not self.prepare_downstream_git(project_fork):
Expand Down
19 changes: 10 additions & 9 deletions betka/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def __init__(self, betka_config: Dict, config_json: Dict):
self.config_json = config_json
self.gitlab_api_url: str = f"{self.config_json['gitlab_api_url']}"
self.git = Git()
self.clone_url: str = ""
self.upstream_clone_url: str = ""
self.ssh_url_to_repo: str = ""
self.forked_ssh_url_to_repo: str = ""
self.image: str = ""
self._gitlab_api = None
self.gitlab_user = ""
Expand Down Expand Up @@ -240,7 +240,8 @@ def fork_project(self) -> Any:
return None

self.fork_id = fork.id
self.clone_url = fork.ssh_url_to_repo
self.ssh_url_to_repo = fork.ssh_url_to_repo
self.forked_ssh_url_to_repo = fork.forked_ssh_url_to_repo
try:
self.load_forked_project()
except BetkaException:
Expand Down Expand Up @@ -432,11 +433,11 @@ def get_branches(self) -> List[str]:
branches_list.append(brn.name)
return branches_list

def get_clone_url(self) -> str:
return self.clone_url
def get_ssh_url_to_repo(self) -> str:
return self.ssh_url_to_repo

def get_upstream_clone_url(self) -> str:
return self.upstream_clone_url
def get_forked_ssh_url_to_repo(self) -> str:
return self.forked_ssh_url_to_repo

def get_gitlab_fork(self) -> Any:
"""
Expand All @@ -452,8 +453,8 @@ def get_gitlab_fork(self) -> Any:
continue
if fork.username != self.betka_config["gitlab_user"]:
continue
self.clone_url = fork.ssh_url_to_repo
self.upstream_clone_url = fork.forked_ssh_url_to_repo
self.ssh_url_to_repo = fork.ssh_url_to_repo
self.forked_ssh_url_to_repo = fork.forked_ssh_url_to_repo
logger.debug(f"Project fork found: {fork}")
self.fork_id = fork.id
self.load_forked_project()
Expand Down

0 comments on commit dd2a525

Please sign in to comment.