Merge ~medicalwei/germinate:handle-git-subdir into germinate:master

Proposed by Yao Wei
Status: Needs review
Proposed branch: ~medicalwei/germinate:handle-git-subdir
Merge into: germinate:master
Diff against target: 28 lines (+9/-1)
1 file modified
germinate/seeds.py (+9/-1)
Reviewer Review Type Date Requested Status
Julian Andres Klode Needs Information
Review via email: mp+457143@code.launchpad.net

Commit message

Handle including git subdir like "ubuntu.noble/languages"

This will assume we don't have / in our git branch names.

To post a comment you must log in.
67e4aed... by Yao Wei

Handle including git subdir like "ubuntu.noble/languages"

Previously, to check out seeds in Bazaar repos, we use
notations like "ubuntu.noble/languages" to indicate checking
out "languages" subdirectory inside "noble" branch.

This workaround is to ensure the backward compatibility with
bzr repos. However, this implies we cannot include "/" in
git branch name, otherwise it will be recognized as a
subdirectory name in germinate.

Git itself does not provide a convenient function to check
out a subdirectory of a repo, therefore we remove the path
and attempt to check out the entire repo, which it might be
previously checked out.

Revision history for this message
Julian Andres Klode (juliank) wrote :

Can you explain the use case in the commit message and add the caveat there as well?

I don't like blindly merging features without knowing what they're for and there may be better solutions too.

review: Needs Information
Revision history for this message
Yao Wei (medicalwei) wrote :

I updated the commit messages, hope that would get a good enough explanations. However, since I am still not understanding how it was designed, my proposal might get totally wrong.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :
Revision history for this message
Yao Wei (medicalwei) wrote :

Yes, should we change that line for this instance?

Revision history for this message
Yao Wei (medicalwei) wrote :

> The usage that is causing the problem is here, right?
> https://git.launchpad.net/~oem-solutions-engineers/ubuntu-seeds/+git/ubuntu-
> oem/tree/STRUCTURE?h=noble#n2

Now I realized why it didn't happen in stock Ubuntu: because "ubuntu.noble" was checked out already so "ubuntu.noble/language" directory exists.

However, as for ubuntu-oem, it checks out "ubuntu-oem.noble" but not "ubuntu.noble", therefore "ubuntu.noble/language" does not exist, triggering this issue.

Revision history for this message
Yao Wei (medicalwei) wrote :

I realized the issue is triggered by my misuse of seeds format, but I'll still keep the MP here since it is a possible issue for germinate.

Unmerged commits

67e4aed... by Yao Wei

Handle including git subdir like "ubuntu.noble/languages"

Previously, to check out seeds in Bazaar repos, we use
notations like "ubuntu.noble/languages" to indicate checking
out "languages" subdirectory inside "noble" branch.

This workaround is to ensure the backward compatibility with
bzr repos. However, this implies we cannot include "/" in
git branch name, otherwise it will be recognized as a
subdirectory name in germinate.

Git itself does not provide a convenient function to check
out a subdirectory of a repo, therefore we remove the path
and attempt to check out the entire repo, which it might be
previously checked out.

Succeeded
[SUCCEEDED] test:0 (build)
11 of 1 result

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/germinate/seeds.py b/germinate/seeds.py
2index fe15734..361385e 100644
3--- a/germinate/seeds.py
4+++ b/germinate/seeds.py
5@@ -133,6 +133,14 @@ class Seed:
6 if _vcs_cache_dir is None:
7 _vcs_cache_dir = tempfile.mkdtemp(prefix="germinate-")
8 atexit.register(shutil.rmtree, _vcs_cache_dir, ignore_errors=True)
9+
10+ # Handling checking out directory of a git repo,
11+ # e.g. "ubuntu.noble/languages"
12+ # This assumes we don't have "/" in the branch name.
13+ subdir = ""
14+ if "/" in branch:
15+ branch, subdir = branch.split("/", 1)
16+
17 checkout = os.path.join(_vcs_cache_dir, branch)
18 if not os.path.isdir(checkout):
19 # This is a very strange way to specify a git branch, but it's
20@@ -161,7 +169,7 @@ class Seed:
21 "Command failed with exit status %d:\n"
22 " '%s'" % (status, " ".join(command))
23 )
24- return open(os.path.join(checkout, name))
25+ return open(os.path.join(checkout, subdir, name))
26
27 def _open_seed_url(self, base, branch, name):
28 path = os.path.join(base, branch)

Subscribers

People subscribed via source and target branches

to all changes: