From d5fd5447660bd50c4a9f16478face7738c1aa8c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Tue, 19 Nov 2024 22:21:58 -0800 Subject: [PATCH 1/2] Use DEP-14 branch names `debian/latest` and `upstream/latest` In DEP-14, the preferred branch name for the Debian packaging target branch is `debian/latest` and the preferred name for the upstream import target branch is `upstream/latest`. Note that the upstream development branch name can be whatever and should stay as it is upstream, typically `main` or `master`. The branch `upstream/latest` should not point to the latest upstream development commit, but to the latest commit that was used as the upstream release that the Debian revision was derived from. --- make.go | 14 +++++++++----- template.go | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/make.go b/make.go index a8bd901..fa6a6ab 100644 --- a/make.go +++ b/make.go @@ -416,7 +416,8 @@ 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) { wd, err := os.Getwd() if err != nil { return "", fmt.Errorf("get cwd: %w", err) @@ -462,7 +463,7 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream, // Preconfigure branches - branches := []string{debianBranch, "upstream"} + branches := []string{debianBranch, "upstream/latest"} if pristineTar { branches = append(branches, "pristine-tar") } @@ -496,6 +497,9 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream, // Import upstream orig tarball arg := []string{"import-orig", "--no-interactive", "--debian-branch=" + debianBranch} + if dep14 { + arg = append(arg, "--upstream-branch=upstream/latest") + } if pristineTar { arg = append(arg, "--pristine-tar") } @@ -777,7 +781,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 +891,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 +982,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 { From 871028376bd26f1190ec3f33d9fceec635078427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Thu, 21 Nov 2024 00:18:30 -0800 Subject: [PATCH 2/2] Always call upstream git remote `upstreamvcs` Instead of using various different upstream remote names, use the one and same upstream git remote name consistently. As the name pick `upstreamvcs` just as git-buildpackage does, so that if anybody runs `gbp clone` they will automatically end up with the same git remotes and branches as anyone in to go-team. --- make.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/make.go b/make.go index fa6a6ab..e0bd1dc 100644 --- a/make.go +++ b/make.go @@ -418,6 +418,14 @@ func runGitCommandIn(dir string, arg ...string) error { func createGitRepository(debsrc, gopkg, orig string, u *upstream, 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) @@ -463,7 +471,8 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream, // Preconfigure branches - branches := []string{debianBranch, "upstream/latest"} + branches := []string{debianBranch, upstreamImportBranch} + if pristineTar { branches = append(branches, "pristine-tar") } @@ -477,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) @@ -495,10 +499,13 @@ 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} - if dep14 { - arg = append(arg, "--upstream-branch=upstream/latest") + arg := []string{ + "import-orig", + "--no-interactive", + "--debian-branch=" + debianBranch, + "--upstream-branch=" + upstreamImportBranch, } if pristineTar { arg = append(arg, "--pristine-tar")