diff --git a/make.go b/make.go index a8bd901..e0bd1dc 100644 --- a/make.go +++ b/make.go @@ -416,7 +416,16 @@ func runGitCommandIn(dir string, arg ...string) error { } func createGitRepository(debsrc, gopkg, orig string, u *upstream, - includeUpstreamHistory bool, allowUnknownHoster bool, debianBranch string, pristineTar bool) (string, error) { + includeUpstreamHistory bool, allowUnknownHoster bool, debianBranch string, + dep14 bool, pristineTar bool) (string, error) { + + // debianBranch is passed in function call, but upstream import branch needs + // also to be defined + upstreamImportBranch := "upstream" + if dep14 { + upstreamImportBranch = "upstream/latest" + } + wd, err := os.Getwd() if err != nil { return "", fmt.Errorf("get cwd: %w", err) @@ -462,7 +471,8 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream, // Preconfigure branches - branches := []string{debianBranch, "upstream"} + branches := []string{debianBranch, upstreamImportBranch} + if pristineTar { branches = append(branches, "pristine-tar") } @@ -476,13 +486,8 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream, } if includeUpstreamHistory { - u.remote, err = shortHostName(gopkg, allowUnknownHoster) - if err != nil { - return dir, fmt.Errorf("unable to fetch upstream history: %q", err) - } - if u.remote == "debian" { - u.remote = "salsa" - } + // Always call the upstream git remote 'upstreamvcs' just like git-buildpackage does + u.remote = "upstreamvcs" log.Printf("Adding remote %q with URL %q\n", u.remote, u.rr.Repo) if err := runGitCommandIn(dir, "remote", "add", u.remote, u.rr.Repo); err != nil { return dir, fmt.Errorf("git remote add %s %s: %w", u.remote, u.rr.Repo, err) @@ -494,8 +499,14 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream, } // Import upstream orig tarball + // (and release git tag if includeUpstreamHistory) - arg := []string{"import-orig", "--no-interactive", "--debian-branch=" + debianBranch} + arg := []string{ + "import-orig", + "--no-interactive", + "--debian-branch=" + debianBranch, + "--upstream-branch=" + upstreamImportBranch, + } if pristineTar { arg = append(arg, "--pristine-tar") } @@ -777,7 +788,7 @@ func execMake(args []string, usage func()) { fs.BoolVar(&dep14, "dep14", true, - "Follow DEP-14 branch naming and use debian/sid (instead of master)\n"+ + "Follow DEP-14 branch naming and use debian/latest (instead of master)\n"+ "as the default debian-branch.") var pristineTar bool @@ -887,7 +898,7 @@ func execMake(args []string, usage func()) { // Set the debian branch. debBranch := "master" if dep14 { - debBranch = "debian/sid" + debBranch = "debian/latest" } switch strings.TrimSpace(wrapAndSort) { @@ -978,7 +989,7 @@ func execMake(args []string, usage func()) { debversion := u.version + "-1" - dir, err := createGitRepository(debsrc, gopkg, orig, u, includeUpstreamHistory, allowUnknownHoster, debBranch, pristineTar) + dir, err := createGitRepository(debsrc, gopkg, orig, u, includeUpstreamHistory, allowUnknownHoster, debBranch, dep14, pristineTar) if err != nil { log.Fatalf("Could not create git repository: %v\n", err) } diff --git a/template.go b/template.go index 9cd5edf..55b6c92 100644 --- a/template.go +++ b/template.go @@ -337,7 +337,8 @@ func writeDebianGbpConf(dir string, dep14, pristineTar bool) error { fmt.Fprintf(f, "[DEFAULT]\n") if dep14 { - fmt.Fprintf(f, "debian-branch = debian/sid\n") + fmt.Fprintf(f, "debian-branch = debian/latest\n") + fmt.Fprintf(f, "upstream-branch = upstream/latest\n") fmt.Fprintf(f, "dist = DEP14\n") } if pristineTar {