[PATCH 1/1] repos: only fetch on update if commit is not pinned

0 views
Skip to first unread message

Felix Moessbauer

unread,
Oct 1, 2025, 7:23:51 AMOct 1
to kas-...@googlegroups.com, jan.k...@siemens.com, Felix Moessbauer
In case the checkout is executed with --update and the commit of a repo
is pinned (directly via the config, not via a lockfile), we can safely
skip the fetching if we already have that commit. This slightly speeds
the checkout up as no irrelevant fetch is executed in this case.

Closes: #164
Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
kas/repos.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kas/repos.py b/kas/repos.py
index 187f94305..4b6ff440f 100644
--- a/kas/repos.py
+++ b/kas/repos.py
@@ -406,7 +406,10 @@ class RepoImpl(Repo):
and self.refspec is None:
return 0

- if not get_context().update:
+ # check if we already have the commit. On update, check as well in case
+ # the commit is fixed, hence the repo must not be updated anyways
+ force_update = get_context().update
+ if not force_update or (force_update and self.commit):
# Do commit/tag/branch/refspec exist in the current repository?
(retc, output) = await run_cmd_async(self.contains_refspec_cmd(),
cwd=self.path,
--
2.51.0

Jan Kiszka

unread,
Oct 2, 2025, 6:33:48 AMOct 2
to Felix Moessbauer, kas-...@googlegroups.com
Thanks, applied.

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center
Reply all
Reply to author
Forward
0 new messages