mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-29 17:57:18 +00:00
Compare commits
4 Commits
214d6d7fdd
...
98f2f19d5b
Author | SHA1 | Date | |
---|---|---|---|
98f2f19d5b | |||
5c4d3eeffd | |||
84d4523e85 | |||
2c2eae2334 |
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 7.0.4 (0)
|
||||
<!-- Generated by graphviz version 7.0.5 (0)
|
||||
-->
|
||||
<!-- Title: G Pages: 1 -->
|
||||
<svg width="15156pt" height="5118pt"
|
||||
|
Before Width: | Height: | Size: 641 KiB After Width: | Height: | Size: 641 KiB |
@ -1,4 +1,4 @@
|
||||
.TH AHRIMAN "1" "2022\-12\-31" "ahriman" "Generated Python Manual"
|
||||
.TH AHRIMAN "1" "2023\-01\-02" "ahriman" "Generated Python Manual"
|
||||
.SH NAME
|
||||
ahriman
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Maintainer: Evgeniy Alekseev
|
||||
|
||||
pkgname='ahriman'
|
||||
pkgver=2.5.1
|
||||
pkgver=2.5.3
|
||||
pkgrel=1
|
||||
pkgdesc="ArcH linux ReposItory MANager"
|
||||
arch=('any')
|
||||
|
@ -58,23 +58,26 @@ class _Context:
|
||||
raise ValueError(f"Value {value} is not an instance of {key.return_type}")
|
||||
return value
|
||||
|
||||
def set(self, key: ContextKey[T], value: T) -> None:
|
||||
def set(self, key: ContextKey[T], value: T, strict: bool = True) -> None:
|
||||
"""
|
||||
set value for the specified key
|
||||
|
||||
Args:
|
||||
key(ContextKey[T]): context key name
|
||||
value(T): context value associated with the specified key
|
||||
strict(bool, optional): check if key already exists (Default value = True)
|
||||
|
||||
Raises:
|
||||
KeyError: in case if the specified context variable already exists
|
||||
ValueError: in case if type of value is not an instance of specified return type
|
||||
"""
|
||||
if key.key in self._content:
|
||||
has_key = key.key in self._content
|
||||
if strict and has_key:
|
||||
raise KeyError(key.key)
|
||||
if not isinstance(value, key.return_type):
|
||||
raise ValueError(f"Value {value} is not an instance of {key.return_type}")
|
||||
self._content[key.key] = value
|
||||
if not has_key:
|
||||
self._content[key.key] = value
|
||||
|
||||
def __iter__(self) -> Iterator[str]:
|
||||
"""
|
||||
|
@ -81,7 +81,8 @@ class RemotePush(LazyLogging):
|
||||
# ...secondly, we clone whole tree...
|
||||
Sources.fetch(package_target_dir, package.remote)
|
||||
# ...and last, but not least, we remove the dot-git directory...
|
||||
shutil.rmtree(package_target_dir / ".git", ignore_errors=True)
|
||||
for git_file in package_target_dir.glob(".git*"):
|
||||
shutil.rmtree(package_target_dir / git_file)
|
||||
# ...copy all patches...
|
||||
for patch in self.database.patches_get(package.base):
|
||||
filename = f"ahriman-{package.base}.patch" if patch.key is None else f"ahriman-{patch.key}.patch"
|
||||
|
@ -83,12 +83,12 @@ class Repository(Executor, UpdateHandler):
|
||||
"""
|
||||
ctx = context.get()
|
||||
|
||||
ctx.set(ContextKey("database", SQLite), self.database)
|
||||
ctx.set(ContextKey("configuration", Configuration), self.configuration)
|
||||
ctx.set(ContextKey("pacman", Pacman), self.pacman)
|
||||
ctx.set(ContextKey("sign", GPG), self.sign)
|
||||
ctx.set(ContextKey("database", SQLite), self.database, strict=False)
|
||||
ctx.set(ContextKey("configuration", Configuration), self.configuration, strict=False)
|
||||
ctx.set(ContextKey("pacman", Pacman), self.pacman, strict=False)
|
||||
ctx.set(ContextKey("sign", GPG), self.sign, strict=False)
|
||||
|
||||
ctx.set(ContextKey("repository", type(self)), self)
|
||||
ctx.set(ContextKey("repository", type(self)), self, strict=False)
|
||||
|
||||
context.set(ctx)
|
||||
|
||||
|
@ -17,4 +17,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
__version__ = "2.5.1"
|
||||
__version__ = "2.5.3"
|
||||
|
@ -20,18 +20,21 @@ def test_package_update(database: SQLite, configuration: Configuration, package_
|
||||
"""
|
||||
patch1 = PkgbuildPatch(None, "patch")
|
||||
patch2 = PkgbuildPatch("key", "value")
|
||||
local = Path("local")
|
||||
|
||||
glob_mock = mocker.patch("pathlib.Path.glob", return_value=[".git", ".gitignore"])
|
||||
rmtree_mock = mocker.patch("shutil.rmtree")
|
||||
fetch_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.fetch")
|
||||
patches_mock = mocker.patch("ahriman.core.database.SQLite.patches_get", return_value=[patch1, patch2])
|
||||
patches_write_mock = mocker.patch("ahriman.models.pkgbuild_patch.PkgbuildPatch.write")
|
||||
runner = RemotePush(configuration, database, "gitremote")
|
||||
|
||||
local = Path("local")
|
||||
assert runner.package_update(package_ahriman, local) == package_ahriman.base
|
||||
glob_mock.assert_called_once_with(".git*")
|
||||
rmtree_mock.assert_has_calls([
|
||||
MockCall(local / package_ahriman.base, ignore_errors=True),
|
||||
MockCall(local / package_ahriman.base / ".git", ignore_errors=True),
|
||||
MockCall(local / package_ahriman.base / ".git"),
|
||||
MockCall(local / package_ahriman.base / ".gitignore"),
|
||||
])
|
||||
fetch_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman.remote)
|
||||
patches_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
@ -32,11 +32,11 @@ def test_set_context(configuration: Configuration, database: SQLite, mocker: Moc
|
||||
|
||||
instance = Repository.load("x86_64", configuration, database, report=False, unsafe=False)
|
||||
set_mock.assert_has_calls([
|
||||
MockCall(ContextKey("database", SQLite), instance.database),
|
||||
MockCall(ContextKey("configuration", Configuration), instance.configuration),
|
||||
MockCall(ContextKey("pacman", Pacman), instance.pacman),
|
||||
MockCall(ContextKey("sign", GPG), instance.sign),
|
||||
MockCall(ContextKey("repository", Repository), instance),
|
||||
MockCall(ContextKey("database", SQLite), instance.database, strict=False),
|
||||
MockCall(ContextKey("configuration", Configuration), instance.configuration, strict=False),
|
||||
MockCall(ContextKey("pacman", Pacman), instance.pacman, strict=False),
|
||||
MockCall(ContextKey("sign", GPG), instance.sign, strict=False),
|
||||
MockCall(ContextKey("repository", Repository), instance, strict=False),
|
||||
])
|
||||
|
||||
|
||||
|
@ -57,6 +57,17 @@ def test_set_value_exception() -> None:
|
||||
ctx.set(ContextKey("key", str), 42)
|
||||
|
||||
|
||||
def test_set_value_exists() -> None:
|
||||
"""
|
||||
must skip key set in case if key already exists and strict check is disabled
|
||||
"""
|
||||
key, value = ContextKey("key", int), 42
|
||||
ctx = _Context()
|
||||
ctx.set(key, value)
|
||||
|
||||
ctx.set(key, value, strict=False)
|
||||
|
||||
|
||||
def test_contains() -> None:
|
||||
"""
|
||||
must correctly check if element is in list
|
||||
|
Loading…
Reference in New Issue
Block a user