@@ -416,16 +416,7 @@ func runGitCommandIn(dir string, arg ...string) error {
416
416
}
417
417
418
418
func createGitRepository (debsrc , gopkg , orig string , u * upstream ,
419
- includeUpstreamHistory bool , allowUnknownHoster bool , debianBranch string ,
420
- dep14 bool , pristineTar bool ) (string , error ) {
421
-
422
- // debianBranch is passed in function call, but upstream import branch needs
423
- // also to be defined
424
- upstreamImportBranch := "upstream"
425
- if dep14 {
426
- upstreamImportBranch = "upstream/latest"
427
- }
428
-
419
+ includeUpstreamHistory bool , allowUnknownHoster bool , debianBranch string , pristineTar bool ) (string , error ) {
429
420
wd , err := os .Getwd ()
430
421
if err != nil {
431
422
return "" , fmt .Errorf ("get cwd: %w" , err )
@@ -471,8 +462,7 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
471
462
472
463
// Preconfigure branches
473
464
474
- branches := []string {debianBranch , upstreamImportBranch }
475
-
465
+ branches := []string {debianBranch , "upstream" }
476
466
if pristineTar {
477
467
branches = append (branches , "pristine-tar" )
478
468
}
@@ -486,8 +476,13 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
486
476
}
487
477
488
478
if includeUpstreamHistory {
489
- // Always call the upstream git remote 'upstreamvcs' just like git-buildpackage does
490
- u .remote = "upstreamvcs"
479
+ u .remote , err = shortHostName (gopkg , allowUnknownHoster )
480
+ if err != nil {
481
+ return dir , fmt .Errorf ("unable to fetch upstream history: %q" , err )
482
+ }
483
+ if u .remote == "debian" {
484
+ u .remote = "salsa"
485
+ }
491
486
log .Printf ("Adding remote %q with URL %q\n " , u .remote , u .rr .Repo )
492
487
if err := runGitCommandIn (dir , "remote" , "add" , u .remote , u .rr .Repo ); err != nil {
493
488
return dir , fmt .Errorf ("git remote add %s %s: %w" , u .remote , u .rr .Repo , err )
@@ -499,14 +494,8 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
499
494
}
500
495
501
496
// Import upstream orig tarball
502
- // (and release git tag if includeUpstreamHistory)
503
497
504
- arg := []string {
505
- "import-orig" ,
506
- "--no-interactive" ,
507
- "--debian-branch=" + debianBranch ,
508
- "--upstream-branch=" + upstreamImportBranch ,
509
- }
498
+ arg := []string {"import-orig" , "--no-interactive" , "--debian-branch=" + debianBranch }
510
499
if pristineTar {
511
500
arg = append (arg , "--pristine-tar" )
512
501
}
@@ -521,6 +510,29 @@ func createGitRepository(debsrc, gopkg, orig string, u *upstream,
521
510
return dir , fmt .Errorf ("import-orig: %w" , err )
522
511
}
523
512
513
+ {
514
+ f , err := os .OpenFile (filepath .Join (dir , ".gitignore" ), os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0644 )
515
+ if err != nil {
516
+ return dir , fmt .Errorf ("open .gitignore: %w" , err )
517
+ }
518
+ // Beginning newline in case the file already exists and lacks a newline
519
+ // (not all editors enforce a newline at the end of the file):
520
+ if _ , err := f .Write ([]byte ("\n /.pc/\n /_build/\n " )); err != nil {
521
+ return dir , fmt .Errorf ("write to .gitignore: %w" , err )
522
+ }
523
+ if err := f .Close (); err != nil {
524
+ return dir , fmt .Errorf ("close .gitignore: %w" , err )
525
+ }
526
+ }
527
+
528
+ if err := runGitCommandIn (dir , "add" , ".gitignore" ); err != nil {
529
+ return dir , fmt .Errorf ("git add .gitignore: %w" , err )
530
+ }
531
+
532
+ if err := runGitCommandIn (dir , "commit" , "-m" , "Ignore _build and quilt .pc dirs via .gitignore" ); err != nil {
533
+ return dir , fmt .Errorf ("git commit (.gitignore): %w" , err )
534
+ }
535
+
524
536
return dir , nil
525
537
}
526
538
@@ -765,7 +777,7 @@ func execMake(args []string, usage func()) {
765
777
fs .BoolVar (& dep14 ,
766
778
"dep14" ,
767
779
true ,
768
- "Follow DEP-14 branch naming and use debian/latest (instead of master)\n " +
780
+ "Follow DEP-14 branch naming and use debian/sid (instead of master)\n " +
769
781
"as the default debian-branch." )
770
782
771
783
var pristineTar bool
@@ -875,7 +887,7 @@ func execMake(args []string, usage func()) {
875
887
// Set the debian branch.
876
888
debBranch := "master"
877
889
if dep14 {
878
- debBranch = "debian/latest "
890
+ debBranch = "debian/sid "
879
891
}
880
892
881
893
switch strings .TrimSpace (wrapAndSort ) {
@@ -966,7 +978,7 @@ func execMake(args []string, usage func()) {
966
978
967
979
debversion := u .version + "-1"
968
980
969
- dir , err := createGitRepository (debsrc , gopkg , orig , u , includeUpstreamHistory , allowUnknownHoster , debBranch , dep14 , pristineTar )
981
+ dir , err := createGitRepository (debsrc , gopkg , orig , u , includeUpstreamHistory , allowUnknownHoster , debBranch , pristineTar )
970
982
if err != nil {
971
983
log .Fatalf ("Could not create git repository: %v\n " , err )
972
984
}
0 commit comments