Merge ~nacc/git-ubuntu:repo_builder-patches-applied into git-ubuntu:master

Proposed by Nish Aravamudan
Status: Merged
Merged at revision: 3d8ed66cdcc71eedc2099972cab1e99c0d7646af
Proposed branch: ~nacc/git-ubuntu:repo_builder-patches-applied
Merge into: git-ubuntu:master
Diff against target: 137 lines (+53/-14)
3 files modified
gitubuntu/importer.py (+9/-10)
gitubuntu/repo_builder.py (+9/-2)
gitubuntu/source_builder_test.py (+35/-2)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Andreas Hasenack Approve
Review via email: mp+342800@code.launchpad.net

Commit message

make jenkins happy

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:b5756225b70116c571dd3d710427a6874e0b9211
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/379/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/379/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Looks good.

Could you please also update the test_source_quilt_with_patches() test to check that the patches were *not* applied? i.e., that we do not have the "a" and "b" files.

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Thanks, +1

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:dc2ec6686cc257f4eff1b56b0ee699340de3c725
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/380/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/380/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/gitubuntu/importer.py b/gitubuntu/importer.py
2index c3e2800..478ffa4 100644
3--- a/gitubuntu/importer.py
4+++ b/gitubuntu/importer.py
5@@ -90,11 +90,13 @@ class ParentOverrideError(GitUbuntuImportError):
6 pass
7
8
9-def dsc_to_tree_hash(pygit2_repo, dsc_path):
10+def dsc_to_tree_hash(pygit2_repo, dsc_path, patches_applied=False):
11 '''Convert a dsc file into a git tree in the given repo
12
13 pygit2_repo: pygit2.Repository object
14 dsc_path: string path to dsc file
15+ patches_applied: bool whether patches should be applied on
16+ extraction
17
18 Returns: tree hash as a hex string
19 '''
20@@ -105,15 +107,12 @@ def dsc_to_tree_hash(pygit2_repo, dsc_path):
21 # extracted_dir.
22
23 extracted_dir = os.path.join(temp_dir, 'x')
24- run(
25- [
26- 'dpkg-source',
27- '-x',
28- '--skip-patches',
29- dsc_path,
30- extracted_dir, # this is <temp_dir>/x
31- ]
32- )
33+ cmd = ['dpkg-source', '-x']
34+ if not patches_applied:
35+ cmd.append('--skip-patches')
36+ # extracted_dir is <temp_dir>/x
37+ cmd.extend([dsc_path, extracted_dir])
38+ run(cmd)
39
40 if not os.path.exists(extracted_dir):
41 logging.error("No source extracted?")
42diff --git a/gitubuntu/repo_builder.py b/gitubuntu/repo_builder.py
43index e46650c..94bc62a 100644
44--- a/gitubuntu/repo_builder.py
45+++ b/gitubuntu/repo_builder.py
46@@ -180,21 +180,28 @@ class Tree(NamedMixin, WriteMixin):
47
48
49 class SourceTree(NamedMixin, WriteMixin):
50- def __init__(self, source, **kwargs):
51+ def __init__(self, source, patches_applied=False, **kwargs):
52 """Construct a git tree representation of a source_builder.Source
53
54 :param source_tree.SourceBuilder source: the source whose git tree this
55 object will represent
56+ :param patches_applied bool: whether patches should be applied
57+ in this source tree
58 """
59 super().__init__(**kwargs)
60 self.source = source
61+ self.patches_applied = patches_applied
62
63 def walk(self, parent=None):
64 yield parent, self
65
66 def _obj_to_oid(self, repo, record):
67 with self.source as dsc_path:
68- oid_str = gitubuntu.importer.dsc_to_tree_hash(repo, dsc_path)
69+ oid_str = gitubuntu.importer.dsc_to_tree_hash(
70+ repo,
71+ dsc_path,
72+ self.patches_applied,
73+ )
74 return pygit2.Oid(binascii.unhexlify(oid_str))
75
76
77diff --git a/gitubuntu/source_builder_test.py b/gitubuntu/source_builder_test.py
78index 4b7981a..41a95de 100644
79--- a/gitubuntu/source_builder_test.py
80+++ b/gitubuntu/source_builder_test.py
81@@ -9,14 +9,20 @@ import gitubuntu.git_repository as git_repository
82 from gitubuntu.test_fixtures import repo
83
84
85-def dsc_path_to_tree(repo, dsc_path):
86+def dsc_path_to_tree(repo, dsc_path, patches_applied=False):
87 """Convert a dsc filesystem path to a pygit2.Tree object.
88
89 :param GitUbuntuRepository repo: repository wrapper object
90 :param str dsc_path: path to dsc file
91+ :param bool patches_applied: whether all quilt patches should be
92+ applied during extraction
93 :rtype: pygit2.Tree
94 """
95- tree_hash = importer.dsc_to_tree_hash(repo.raw_repo, dsc_path)
96+ tree_hash = importer.dsc_to_tree_hash(
97+ repo.raw_repo,
98+ dsc_path,
99+ patches_applied,
100+ )
101 return repo.raw_repo.get(tree_hash)
102
103
104@@ -90,6 +96,33 @@ def test_source_quilt_with_patches(repo):
105 top,
106 'debian/patches/%s' % basename,
107 )
108+ unexpected_files = ['a', 'b']
109+ for filename in unexpected_files:
110+ with pytest.raises(KeyError):
111+ git_repository.follow_symlinks_to_blob(
112+ repo.raw_repo,
113+ top,
114+ filename,
115+ )
116+
117+
118+def test_source_quilt_with_patches_applied(repo):
119+ spec = target.SourceSpec(native=False, has_patches=True)
120+ with target.Source(spec) as dsc_path:
121+ top = dsc_path_to_tree(repo, dsc_path, patches_applied=True)
122+ expected_files = [
123+ 'debian/patches/series',
124+ 'debian/patches/a',
125+ 'debian/patches/b',
126+ 'a',
127+ 'b',
128+ ]
129+ for filename in expected_files:
130+ assert git_repository.follow_symlinks_to_blob(
131+ repo.raw_repo,
132+ top,
133+ filename,
134+ )
135
136
137 def test_source_version_native_default(repo):

Subscribers

People subscribed via source and target branches