Skip to content

Commit d9d27ff

Browse files
committed
Switch from tar --exclude-vcs to tar --exclude=.git
This way, upstream’s .gitignore files are preserved (preventing merge conflicts down the road). As an additional bonus, corner cases like a .hg directory in a test fixture directory are also handled correctly. This change is one more lock-in step into a git-only world, but that’s where we’re going anyway, see https://pkg-go.alioth.debian.org/workflow-changes.html fixes #41
1 parent 3d41814 commit d9d27ff

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

make.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func makeUpstreamSourceTarball(gopkg string, gitRevision string, pkgType string)
137137
"tar",
138138
"cJf",
139139
tempfile,
140-
"--exclude-vcs",
140+
"--exclude=.git",
141141
"--exclude=Godeps",
142142
fmt.Sprintf("--exclude=%s/debian", base),
143143
base)
@@ -307,8 +307,19 @@ func createGitRepository(debsrc, gopkg, orig string) (string, error) {
307307
return dir, err
308308
}
309309

310-
if err := ioutil.WriteFile(filepath.Join(dir, ".gitignore"), []byte(".pc\n"), 0644); err != nil {
311-
return dir, err
310+
{
311+
f, err := os.OpenFile(filepath.Join(dir, ".gitignore"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
312+
if err != nil {
313+
return dir, err
314+
}
315+
// Beginning newline in case the file already exists and lacks a newline
316+
// (not all editors enforce a newline at the end of the file):
317+
if _, err := f.Write([]byte("\n.pc\n")); err != nil {
318+
return dir, err
319+
}
320+
if err := f.Close(); err != nil {
321+
return dir, err
322+
}
312323
}
313324

314325
if err := runGitCommandIn(dir, "add", ".gitignore"); err != nil {

0 commit comments

Comments
 (0)