Skip to content

Commit

Permalink
re-init services after loading repo config (#74)
Browse files Browse the repository at this point in the history
* re-init services after loading repo config

* use tomlkit
  • Loading branch information
grizz authored Feb 10, 2024
1 parent e68efee commit 67eb0ea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/ctl/util/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def init_repository(self):
os.makedirs(self.directory)

# init services first to setup auth
# repo config will not have been loaded yet, but we might need a service to clone the repo
self.init_services(self.repository_config)

try:
Expand Down Expand Up @@ -270,8 +271,12 @@ def init_repository(self):
f"Repository initialized at {self.directory} from {self.url} - origin set to {self.origin.name if self.origin else None}"
)

# load the real repo config from the cloned repo
self.load_repository_config(self.repository_config_filename)

# re-init services with the newly loaded config
self.init_services(self.repository_config)

def init_submodules(self):
"""
Initializes and updates existing submodules
Expand Down Expand Up @@ -373,6 +378,8 @@ def service_project(self, service: str = None):
Returns the service project for the service
"""
_service = getattr(self.services, service) if service else self.service
if not _service:
raise ValueError("No service configured, cannot get project")
return _service.get_project_from_url(self.url)

def service_file_url(self, file_path: str, service: str = None):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_plugin_semver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shutil

import pytest
import toml
import tomlkit
from util import instantiate_semver2 as instantiate

import ctl
Expand Down Expand Up @@ -50,7 +50,7 @@ def test_tag_pyproject(tmpdir, ctlr):

plugin.tag(version="2.0.0", repo="dummy_repo", prerelease="rc")

pyproject = toml.load(pyproject_path)
pyproject = tomlkit.load(pyproject_path)
assert pyproject["tool"]["poetry"]["version"] == "2.0.0-rc.1"


Expand Down
4 changes: 2 additions & 2 deletions tests/test_plugin_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shutil

import pytest
import toml
import tomlkit
from util import instantiate_version as instantiate

import ctl
Expand Down Expand Up @@ -48,7 +48,7 @@ def test_tag_pyproject(tmpdir, ctlr):

plugin.tag(version="2.0.0", repo="dummy_repo")

pyproject = toml.load(pyproject_path)
pyproject = tomlkit.load(pyproject_path)
assert pyproject["tool"]["poetry"]["version"] == "2.0.0"


Expand Down

0 comments on commit 67eb0ea

Please sign in to comment.