Skip to content

Commit 43d3722

Browse files
committed
deptool: Moved to one global fetch
Anecdotally, it seems like one git fetch --all --tags will be faster than several specific fetches. It also "avoids" the problem of what the remote is called, previously origin was assumed, however for me the "correct" one to use is upstream, or --all. Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
1 parent 7df1128 commit 43d3722

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/cfengine_cli/deptool.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def __init__(
126126

127127
if not os.path.exists(repo_path):
128128
self.run_command("clone", "--no-checkout", repo_url, repo_path)
129+
self.run_command("fetch", "--all", "--tags")
129130
if checkout_ref is not None:
130131
self.checkout(checkout_ref)
131132

@@ -166,24 +167,17 @@ def run_command(self, *command, **kwargs):
166167

167168
return result
168169

169-
def checkout(self, ref, remote="origin", new=False):
170+
def checkout(self, ref, new=False):
170171
"""Checkout given ref (branch or tag), optionally creating the ref as a branch.
171172
Note that it's an error to create-and-checkout branch which already exists.
172173
"""
173174
if new:
174175
# create new branch
175176
self.run_command("checkout", "-b", ref)
176177
else:
177-
# first, ensure that we're aware of target ref
178-
# TODO: Move this to one global fetch, it will be
179-
# generally faster and not break when remote
180-
# is something else (i.e. upstream, not origin).
181-
# git fetch --all --tags
182-
self.run_command("fetch", remote, ref)
183-
# switch to the ref
184178
self.run_command("checkout", ref)
185179
# ensure we're on the tip of ref
186-
self.run_command("reset", "--hard", "FETCH_HEAD")
180+
self.run_command("reset", "--hard", "HEAD")
187181
self.run_command("submodule", "update", "--init")
188182

189183
def get_file(self, relpath):
@@ -322,6 +316,7 @@ def deps_versions(self, ref):
322316

323317
deps_versions = {}
324318
deps_list = self.deps_list(ref)
319+
assert len(deps_list) > 1
325320
for dep in deps_list:
326321
if dep == "$EMBEDDED_DB":
327322
continue

0 commit comments

Comments
 (0)