Skip to content

Commit c6dd501

Browse files
elboulangeroanthonyfok
authored andcommitted
Set debianBranch in execMake(), use it in createGitRepository()
This minor refactoring prepares the code for the next commit, where we will need to know the Debian branch in `execMake()`.
1 parent ca2ee2c commit c6dd501

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

make.go

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func runGitCommandIn(dir string, arg ...string) error {
385385
}
386386

387387
func createGitRepository(debsrc, gopkg, orig string, u *upstream,
388-
includeUpstreamHistory, allowUnknownHoster, dep14, pristineTar bool) (string, error) {
388+
includeUpstreamHistory bool, allowUnknownHoster bool, debianBranch string, pristineTar bool) (string, error) {
389389
wd, err := os.Getwd()
390390
if err != nil {
391391
return "", err
@@ -395,16 +395,10 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
395395
return "", err
396396
}
397397

398-
if err := runGitCommandIn(dir, "init"); err != nil {
398+
if err := runGitCommandIn(dir, "init", "-b", debianBranch); err != nil {
399399
return dir, err
400400
}
401401

402-
if dep14 {
403-
if err := runGitCommandIn(dir, "checkout", "-q", "-b", "debian/sid"); err != nil {
404-
return dir, err
405-
}
406-
}
407-
408402
// Set repository options
409403

410404
if debianName := getDebianName(); debianName != "TODO" {
@@ -437,12 +431,6 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
437431

438432
// Preconfigure branches
439433

440-
var debianBranch string
441-
if dep14 {
442-
debianBranch = "debian/sid"
443-
} else {
444-
debianBranch = "master"
445-
}
446434
branches := []string{debianBranch, "upstream"}
447435
if pristineTar {
448436
branches = append(branches, "pristine-tar")
@@ -473,10 +461,7 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
473461

474462
// Import upstream orig tarball
475463

476-
arg := []string{"import-orig", "--no-interactive"}
477-
if dep14 {
478-
arg = append(arg, "--debian-branch=debian/sid")
479-
}
464+
arg := []string{"import-orig", "--no-interactive", "--debian-branch=" + debianBranch}
480465
if pristineTar {
481466
arg = append(arg, "--pristine-tar")
482467
}
@@ -859,6 +844,12 @@ func execMake(args []string, usage func()) {
859844
log.Fatalf("-type=%q not recognized, aborting\n", pkgTypeString)
860845
}
861846

847+
// Set the debian branch.
848+
debBranch := "master"
849+
if dep14 {
850+
debBranch = "debian/sid"
851+
}
852+
862853
switch strings.TrimSpace(wrapAndSort) {
863854
case "a":
864855
// Current default, also what "cme fix dpkg" generates
@@ -947,7 +938,7 @@ func execMake(args []string, usage func()) {
947938

948939
debversion := u.version + "-1"
949940

950-
dir, err := createGitRepository(debsrc, gopkg, orig, u, includeUpstreamHistory, allowUnknownHoster, dep14, pristineTar)
941+
dir, err := createGitRepository(debsrc, gopkg, orig, u, includeUpstreamHistory, allowUnknownHoster, debBranch, pristineTar)
951942
if err != nil {
952943
log.Fatalf("Could not create git repository: %v\n", err)
953944
}

0 commit comments

Comments
 (0)