[projects/git-slug] Informacyjny komunikat po pobraniu refs zamiast 'Read remotes data'
arekm
arekm at pld-linux.org
Tue May 12 15:08:25 CEST 2026
commit b8f8ab3ec4c5188b6aa7bb87c08ed5573c19b201
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Mon Apr 6 22:12:42 2026 +0200
Informacyjny komunikat po pobraniu refs zamiast 'Read remotes data'
Teraz: 'Fetched refs for 21345 package(s) from Refs repo'
— mówi ile pakietów znaleziono, co daje użytkownikowi orientację
w skali operacji zanim zacznie się fetch/init/prune.
git_slug/refsdata.py | 2 ++
slug.py | 6 +++++-
tests/test_failure_paths.py | 18 +++++++++++-------
3 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/git_slug/refsdata.py b/git_slug/refsdata.py
index 67592f8..f33332a 100644
--- a/git_slug/refsdata.py
+++ b/git_slug/refsdata.py
@@ -57,6 +57,8 @@ class GitArchiveRefsData(RemoteRefsData):
member = tar.next()
if member.name != REFFILE:
raise RemoteRefsError(REFFILE, fullrefrepo)
+ # mtime of the archive member = last commit time of the Refs repo
+ self.refs_mtime = member.mtime
RemoteRefsData.__init__(self, tar.extractfile(member), pattern, dirpattern)
if archcmd.wait():
raise RemoteRefsError(REFFILE, fullrefrepo)
diff --git a/slug.py b/slug.py
index c4a2fc6..f12bff9 100755
--- a/slug.py
+++ b/slug.py
@@ -608,7 +608,11 @@ def fetch_packages(options, return_all=False):
"""
branch_refs = getrefs(options.branch, options.repopattern)
all_refs = branch_refs
- print('Read remotes data', file=sys.stderr)
+ import datetime
+ refs_time = datetime.datetime.fromtimestamp(
+ branch_refs.refs_mtime, datetime.timezone.utc).astimezone().strftime('%Y-%m-%d %H:%M:%S %Z')
+ print('Fetched {} package ref(s) (last change on server: {})'.format(
+ len(branch_refs.heads), refs_time), file=sys.stderr)
had_errors = False
pkgs_new = []
if options.newpkgs:
diff --git a/tests/test_failure_paths.py b/tests/test_failure_paths.py
index f51e3e2..df56343 100644
--- a/tests/test_failure_paths.py
+++ b/tests/test_failure_paths.py
@@ -185,7 +185,8 @@ def test_fetch_packages_clone_mode_only_fetches_new_repos(monkeypatch, make_opti
heads={
"pkg-new": {"refs/heads/master": "sha-new"},
"pkg-old": {"refs/heads/master": "sha-old"},
- }
+ },
+ refs_mtime=0,
)
captured = {}
@@ -225,7 +226,7 @@ def test_fetch_packages_clone_mode_only_fetches_new_repos(monkeypatch, make_opti
assert result == ["updated-pkg-new"]
assert options.had_errors is False
- assert "Read remotes data" in capsys.readouterr().err
+ assert "Fetched 2 package ref(s) (last change on server:" in capsys.readouterr().err
assert captured["init_args"] == [("pkg-new", options)]
assert len(captured["fetch_args"]) == 1
assert captured["fetch_args"][0][0].path == "/pkgs/pkg-new"
@@ -237,7 +238,8 @@ def test_fetch_packages_marks_errors_on_partial_init_failures(monkeypatch, make_
heads={
"pkg-a": {"refs/heads/master": "sha-a"},
"pkg-b": {"refs/heads/master": "sha-b"},
- }
+ },
+ refs_mtime=0,
)
monkeypatch.setattr(slug, "getrefs", lambda *args: refs)
@@ -268,8 +270,8 @@ def test_fetch_packages_marks_errors_on_partial_init_failures(monkeypatch, make_
def test_fetch_packages_marks_errors_on_prune_delete_failure(monkeypatch, make_options, capsys):
- refs_initial = SimpleNamespace(heads={"keep": {"refs/heads/master": "sha-keep"}})
- refs_full = SimpleNamespace(heads=collections.defaultdict(dict, {"keep": {"refs/heads/master": "sha-keep"}}))
+ refs_initial = SimpleNamespace(heads={"keep": {"refs/heads/master": "sha-keep"}}, refs_mtime=0)
+ refs_full = SimpleNamespace(heads=collections.defaultdict(dict, {"keep": {"refs/heads/master": "sha-keep"}}), refs_mtime=0)
calls = []
def fake_getrefs(*args):
@@ -313,7 +315,8 @@ def test_prune_reuses_refs_when_branch_is_star(monkeypatch, make_options):
def counting_getrefs(*args):
calls.append(args)
return SimpleNamespace(
- heads=collections.defaultdict(dict, {"pkg": {"refs/heads/master": "sha"}})
+ heads=collections.defaultdict(dict, {"pkg": {"refs/heads/master": "sha"}}),
+ refs_mtime=0,
)
monkeypatch.setattr(slug, "getrefs", counting_getrefs)
@@ -344,7 +347,8 @@ def test_prune_fetches_separately_when_branch_is_filtered(monkeypatch, make_opti
def counting_getrefs(*args):
calls.append(args)
return SimpleNamespace(
- heads=collections.defaultdict(dict, {"pkg": {"refs/heads/master": "sha"}})
+ heads=collections.defaultdict(dict, {"pkg": {"refs/heads/master": "sha"}}),
+ refs_mtime=0,
)
monkeypatch.setattr(slug, "getrefs", counting_getrefs)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4a7e426b8f1a3571094b5dc89412bc49b8f29666
More information about the pld-cvs-commit
mailing list