From efb18bfa37d59243982accc432a3b44cd50b4664 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Thu, 17 Sep 2026 16:33:02 +0200 Subject: [PATCH] new: fix dead patterns in the generated debian/.gitignore Patterns containing a slash are anchored relative to the directory holding the .gitignore, so 'debian/files' inside debian/.gitignore only ever matched debian/debian/files: every generated pattern was dead and debhelper artifacts showed up as untracked. Write the patterns relative to debian/ instead. --- src/new/debian.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/new/debian.rs b/src/new/debian.rs index e03c811..df4ff40 100644 --- a/src/new/debian.rs +++ b/src/new/debian.rs @@ -306,17 +306,19 @@ fn copyright(opts: &NewOptions) -> OutputFile { OutputFile::new("debian/copyright", out) } -/// `debian/.gitignore`: the debhelper build artifacts. +/// `debian/.gitignore`: the debhelper build artifacts. The patterns are +/// relative to `debian/` itself (a `debian/`-prefixed pattern would be +/// anchored to `debian/debian/` inside this file, per gitignore(5)). fn debian_gitignore(opts: &NewOptions) -> OutputFile { OutputFile::new( "debian/.gitignore", format!( - "debian/files\n\ - debian/.debhelper/\n\ - debian/*.log\n\ - debian/{}/\n\ - debian/debhelper-build-stamp\n\ - debian/*.substvars\n", + "files\n\ + .debhelper/\n\ + *.log\n\ + {}/\n\ + debhelper-build-stamp\n\ + *.substvars\n", opts.name ), ) @@ -766,8 +768,8 @@ mod tests { let g = super::debian_gitignore(&opts()); assert_eq!( g.contents, - "debian/files\ndebian/.debhelper/\ndebian/*.log\ndebian/mytool/\n\ - debian/debhelper-build-stamp\ndebian/*.substvars\n" + "files\n.debhelper/\n*.log\nmytool/\n\ + debhelper-build-stamp\n*.substvars\n" ); }