Merge ~cjwatson/launchpad-buildd:fix-shallow-clones into launchpad-buildd:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 82287bcac6685312e6bbb288daaba40a7de0e45a
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad-buildd:fix-shallow-clones
Merge into: launchpad-buildd:master
Diff against target: 70 lines (+11/-5)
3 files modified
debian/changelog (+2/-0)
lpbuildd/target/tests/test_build_oci.py (+8/-4)
lpbuildd/target/vcs.py (+1/-1)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+419243@code.launchpad.net

Commit message

Fix use of shallow clones for OCI builds

Description of the change

This regressed in version 211, since "git clone --depth 1" no longer clones the history of the correct branch when the -b option isn't used. Adding --no-single-branch works around this.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index e0f1e30..2ebc61f 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,6 +1,8 @@
6 launchpad-buildd (212) UNRELEASED; urgency=medium
7
8 * Ensure that launchpad-buildd runs with lxd as a supplementary group.
9+ * Fix use of shallow clones for OCI builds, which regressed in version 211
10+ (LP: #1968630).
11
12 -- Colin Watson <cjwatson@ubuntu.com> Wed, 06 Apr 2022 12:46:35 +0100
13
14diff --git a/lpbuildd/target/tests/test_build_oci.py b/lpbuildd/target/tests/test_build_oci.py
15index add1f86..7e9c916 100644
16--- a/lpbuildd/target/tests/test_build_oci.py
17+++ b/lpbuildd/target/tests/test_build_oci.py
18@@ -179,7 +179,8 @@ class TestBuildOCI(TestCase):
19 build_oci.repo()
20 self.assertThat(build_oci.backend.run.calls, MatchesListwise([
21 RanBuildCommand(
22- ["git", "clone", "-n", "--depth", "1", "lp:foo", "test-image"],
23+ ["git", "clone", "-n", "--depth", "1", "--no-single-branch",
24+ "lp:foo", "test-image"],
25 cwd="/home/buildd"),
26 RanBuildCommand(
27 ["git", "checkout", "-q", "HEAD"],
28@@ -201,7 +202,8 @@ class TestBuildOCI(TestCase):
29 build_oci.repo()
30 self.assertThat(build_oci.backend.run.calls, MatchesListwise([
31 RanBuildCommand(
32- ["git", "clone", "-n", "--depth", "1", "lp:foo", "test-image"],
33+ ["git", "clone", "-n", "--depth", "1", "--no-single-branch",
34+ "lp:foo", "test-image"],
35 cwd="/home/buildd"),
36 RanBuildCommand(
37 ["git", "checkout", "-q", "next"],
38@@ -224,7 +226,8 @@ class TestBuildOCI(TestCase):
39 build_oci.repo()
40 self.assertThat(build_oci.backend.run.calls, MatchesListwise([
41 RanBuildCommand(
42- ["git", "clone", "-n", "--depth", "1", "lp:foo", "test-image"],
43+ ["git", "clone", "-n", "--depth", "1", "--no-single-branch",
44+ "lp:foo", "test-image"],
45 cwd="/home/buildd"),
46 RanBuildCommand(
47 ["git", "checkout", "-q", "refs/tags/1.0"],
48@@ -254,7 +257,8 @@ class TestBuildOCI(TestCase):
49 }
50 self.assertThat(build_oci.backend.run.calls, MatchesListwise([
51 RanBuildCommand(
52- ["git", "clone", "-n", "--depth", "1", "lp:foo", "test-image"],
53+ ["git", "clone", "-n", "--depth", "1", "--no-single-branch",
54+ "lp:foo", "test-image"],
55 cwd="/home/buildd", **env),
56 RanBuildCommand(
57 ["git", "checkout", "-q", "HEAD"],
58diff --git a/lpbuildd/target/vcs.py b/lpbuildd/target/vcs.py
59index fadc2c3..6cb0b8f 100644
60--- a/lpbuildd/target/vcs.py
61+++ b/lpbuildd/target/vcs.py
62@@ -74,7 +74,7 @@ class VCSOperationMixin(StatusOperationMixin):
63 if quiet:
64 cmd.append("-q")
65 if git_shallow_clone:
66- cmd.extend(["--depth", "1"])
67+ cmd.extend(["--depth", "1", "--no-single-branch"])
68 cmd.extend([self.args.git_repository, name])
69 if not self.ssl_verify:
70 env["GIT_SSL_NO_VERIFY"] = "1"

Subscribers

People subscribed via source and target branches