Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/chapters/building.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
state of the current index, which can be used to include staged but uncommitted
changes in the build. Whereas the special argument
<replaceable>WC</replaceable> exports the current working copy as is.</para>
<para>By default uncommitted changes are not exported and
&gbp-buildpackage; aborts when it finds them. Passing
<option>--git-ignore-new</option> includes the uncommitted changes (both
modified and untracked files) in the exported tree, mirroring the behaviour
of building without <option>--git-export-dir</option>.</para>
<para>If you want to default to build in a separate build area, you can
specify the directory to use in the <filename>gbp.conf</filename> file.
<programlisting>
Expand Down
6 changes: 5 additions & 1 deletion docs/manpages/gbp-buildpackage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,11 @@
<para>
Don't abort if there are uncommitted changes in the source tree or
the current branch doesn't match the
<replaceable>DEBIAN-BRANCH</replaceable>.
<replaceable>DEBIAN-BRANCH</replaceable>. The uncommitted changes
are included in the build. This holds whether or not
<option>--git-export-dir</option> is used, as long as
<option>--git-export</option> is left at its default
(<replaceable>HEAD</replaceable>).
</para>
</listitem>
</varlistentry>
Expand Down
7 changes: 7 additions & 0 deletions gbp/scripts/buildpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ def maybe_write_tree(repo: DebianGitRepository, options: optparse.Values) -> str
tree = repo.write_tree()
elif options.export == wc_name:
tree = write_wc(repo)
elif options.ignore_new and options.export == 'HEAD':
# --git-ignore-new asks to build with the uncommitted changes
# in the source tree. Without an export-dir we build in the
# working copy and the changes are included, so export the
# working copy here too to keep the behaviour consistent
# (#1091531).
tree = write_wc(repo)
else:
tree = options.export
if not repo.has_treeish(tree):
Expand Down
31 changes: 31 additions & 0 deletions tests/component/deb/test_buildpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,37 @@ def test_export_wc_buildpackage(self, repo):
self._test_buildpackage(repo, ["--git-export=WC", "--git-export-dir=../foo/bar"])
assert os.path.exists("../foo/bar")

@RepoFixtures.quilt30()
def test_export_dir_ignore_new(self, repo):
"""
Test that --git-ignore-new includes uncommitted changes in the export
when an export dir is used (#1091531).

Without an export dir the package is built in-place in the working copy
so uncommitted changes are always part of the build. With an export dir
the tree to export defaults to HEAD, which used to silently drop those
changes. Before the fix both assertions below failed because HEAD was
exported instead of the working copy.
"""
# Uncommitted modification to a tracked file ...
rules = os.path.join(repo.path, 'debian', 'rules')
with open(rules, 'a') as f:
f.write('\n# uncommitted-marker\n')
# ... and an untracked new file
with open(os.path.join(repo.path, 'untracked.txt'), 'w') as f:
f.write('untracked')

self._test_buildpackage(repo, ['--git-ignore-new',
'--git-no-purge',
'--git-export-dir=../bdir'])

exported = '../bdir/hello-debhelper-2.8'
with open(os.path.join(exported, 'debian', 'rules')) as f:
assert '# uncommitted-marker' in f.read(), \
"Uncommitted change to tracked file was not exported"
assert os.path.exists(os.path.join(exported, 'untracked.txt')), \
"Untracked file was not exported"

@RepoFixtures.native()
def test_argument_quoting(self, repo):
"""Test that we quote arguments to builder (#850869)"""
Expand Down