@@ -9,7 +9,6 @@ import { md2text } from "./markdown-renderer.js";
9
9
import { IPatchSeriesMetadata } from "./patch-series-metadata.js" ;
10
10
import { PatchSeriesOptions } from "./patch-series-options.js" ;
11
11
import { IConfig } from "./project-config.js" ;
12
- import { ProjectOptions } from "./project-options.js" ;
13
12
import { getPullRequestKeyFromURL } from "./pullRequestKey.js" ;
14
13
15
14
export interface ILogger {
@@ -138,19 +137,33 @@ export class PatchSeries {
138
137
throw new Error ( `Cannot find base branch ${ basedOn } ` ) ;
139
138
}
140
139
141
- const project = await ProjectOptions . get ( config , workDir , headCommit , cc , baseCommit , basedOn ) ;
142
140
if ( rangeDiff ) {
143
141
options . rangeDiff = rangeDiff ;
144
142
}
145
143
144
+ cc . push ( ...config . project . cc ) ;
145
+ // Hard-code a check for gitgitgadget/git whether this is a Git GUI PR
146
+ // and hence needs the Git GUI maintainer to be Cc:ed
147
+ if (
148
+ `${ config . repo . owner } /${ config . repo . name } ` === "gitgitgadget/git" &&
149
+ ( await revParse ( `${ baseCommit } :git-gui.sh` , workDir ) ) !== undefined
150
+ ) {
151
+ // Git GUI
152
+ cc . push ( "Johannes Sixt <[email protected] >" ) ;
153
+ }
154
+
146
155
return new PatchSeries (
147
156
config ,
148
157
notes ,
149
158
options ,
150
- project ,
151
159
metadata ,
152
160
rangeDiffRanges ,
153
161
patchCount ,
162
+ cc ,
163
+ workDir ,
164
+ headCommit ,
165
+ baseCommit ,
166
+ basedOn ,
154
167
coverLetter ,
155
168
senderName ,
156
169
) ;
@@ -525,9 +538,13 @@ export class PatchSeries {
525
538
public readonly config : IConfig ;
526
539
public readonly notes : GitNotes ;
527
540
public readonly options : PatchSeriesOptions ;
528
- public readonly project : ProjectOptions ;
529
541
public readonly metadata : IPatchSeriesMetadata ;
530
542
public readonly rangeDiff : IRangeDiff | undefined ;
543
+ public readonly cc : string [ ] ;
544
+ public readonly workDir : string ;
545
+ public readonly headCommit : string ;
546
+ public readonly baseCommit : string ;
547
+ public readonly basedOn ?: string ;
531
548
public readonly coverLetter ?: string ;
532
549
public readonly senderName ?: string ;
533
550
public readonly patchCount : number ;
@@ -536,19 +553,27 @@ export class PatchSeries {
536
553
config : IConfig ,
537
554
notes : GitNotes ,
538
555
options : PatchSeriesOptions ,
539
- project : ProjectOptions ,
540
556
metadata : IPatchSeriesMetadata ,
541
557
rangeDiff : IRangeDiff | undefined ,
542
558
patchCount : number ,
559
+ cc : string [ ] ,
560
+ workDir : string ,
561
+ headCommit : string ,
562
+ baseCommit : string ,
563
+ basedOn ?: string ,
543
564
coverLetter ?: string ,
544
565
senderName ?: string ,
545
566
) {
546
567
this . config = config ;
547
568
this . notes = notes ;
548
569
this . options = options ;
549
- this . project = project ;
550
570
this . metadata = metadata ;
551
571
this . rangeDiff = rangeDiff ;
572
+ this . cc = cc ;
573
+ this . workDir = workDir ;
574
+ this . headCommit = headCommit ;
575
+ this . baseCommit = baseCommit ;
576
+ this . basedOn = basedOn ;
552
577
this . coverLetter = coverLetter ;
553
578
this . senderName = senderName ;
554
579
this . patchCount = patchCount ;
@@ -570,9 +595,9 @@ export class PatchSeries {
570
595
) : Promise < IPatchSeriesMetadata | undefined > {
571
596
let globalOptions : IGitGitGadgetOptions | undefined ;
572
597
if ( this . options . dryRun ) {
573
- logger . log ( `Dry-run ${ this . project . headCommit } v${ this . metadata . iteration } ` ) ;
598
+ logger . log ( `Dry-run ${ this . headCommit } v${ this . metadata . iteration } ` ) ;
574
599
} else {
575
- logger . log ( `Submitting ${ this . project . headCommit } v${ this . metadata . iteration } ` ) ;
600
+ logger . log ( `Submitting ${ this . headCommit } v${ this . metadata . iteration } ` ) ;
576
601
globalOptions = await this . notes . get < IGitGitGadgetOptions > ( "" ) ;
577
602
}
578
603
@@ -582,7 +607,7 @@ export class PatchSeries {
582
607
PatchSeries . cleanUpHeaders ( mails ) ;
583
608
584
609
const ident = await git ( [ "var" , "GIT_AUTHOR_IDENT" ] , {
585
- workDir : this . project . workDir ,
610
+ workDir : this . workDir ,
586
611
} ) ;
587
612
const match = ident . match ( / .* > / ) ;
588
613
const thisAuthor = match && match [ 0 ] ;
@@ -638,7 +663,7 @@ export class PatchSeries {
638
663
const tagMessage = PatchSeries . generateTagMessage (
639
664
mails [ 0 ] ,
640
665
mails . length > 1 ,
641
- this . project . midUrlPrefix ,
666
+ this . config . project . urlPrefix ,
642
667
this . metadata . referencesMessageIds ,
643
668
) ;
644
669
const prKey = getPullRequestKeyFromURL ( this . metadata . pullRequestURL ) ;
@@ -701,7 +726,7 @@ export class PatchSeries {
701
726
this . rangeDiff . previousRange ,
702
727
this . rangeDiff . currentRange ,
703
728
] ,
704
- { workDir : this . project . workDir } ,
729
+ { workDir : this . workDir } ,
705
730
) ;
706
731
// split the range-diff and prefix with a space
707
732
footers . push (
@@ -794,7 +819,7 @@ export class PatchSeries {
794
819
globalOptions . activeMessageIDs [ mid ] = originalCommit ;
795
820
}
796
821
797
- if ( originalCommit && ( await commitExists ( originalCommit , this . project . workDir ) ) ) {
822
+ if ( originalCommit && ( await commitExists ( originalCommit , this . workDir ) ) ) {
798
823
await this . notes . appendCommitNote ( originalCommit , mid ) ;
799
824
}
800
825
}
@@ -840,8 +865,8 @@ export class PatchSeries {
840
865
}
841
866
842
867
protected async generateMBox ( ) : Promise < string > {
843
- const mergeBase = await git ( [ "merge-base" , this . project . baseCommit , this . project . headCommit ] , {
844
- workDir : this . project . workDir ,
868
+ const mergeBase = await git ( [ "merge-base" , this . baseCommit , this . headCommit ] , {
869
+ workDir : this . workDir ,
845
870
} ) ;
846
871
const args = [
847
872
"format-patch" ,
@@ -851,9 +876,9 @@ export class PatchSeries {
851
876
"--add-header=Fcc: Sent" ,
852
877
"--base" ,
853
878
mergeBase ,
854
- this . project . to ,
879
+ `--to= ${ this . config . project . to } ` ,
855
880
] . concat ( PatchSeries . generateSingletonHeaders ( ) ) ;
856
- this . project . cc . map ( ( email ) => {
881
+ this . cc . map ( ( email ) => {
857
882
args . push ( "--cc=" + PatchSeries . encodeSender ( email ) ) ;
858
883
} ) ;
859
884
if ( this . metadata . referencesMessageIds ) {
@@ -867,17 +892,17 @@ export class PatchSeries {
867
892
}
868
893
if ( this . patchCount > 1 ) {
869
894
if ( ! this . coverLetter ) {
870
- throw new Error ( `Branch ${ this . project . headCommit } needs a description` ) ;
895
+ throw new Error ( `Branch ${ this . headCommit } needs a description` ) ;
871
896
}
872
897
args . push ( "--cover-letter" ) ;
873
898
}
874
899
if ( this . options . patience ) {
875
900
args . push ( "--patience" ) ;
876
901
}
877
902
878
- args . push ( `${ this . project . baseCommit } ..${ this . project . headCommit } ` ) ;
903
+ args . push ( `${ this . baseCommit } ..${ this . headCommit } ` ) ;
879
904
880
- return await git ( args , { workDir : this . project . workDir } ) ;
905
+ return await git ( args , { workDir : this . workDir } ) ;
881
906
}
882
907
883
908
protected async generateTagObject ( tagName : string , tagMessage : string ) : Promise < void > {
@@ -887,10 +912,10 @@ export class PatchSeries {
887
912
}
888
913
args . push ( tagName ) ;
889
914
args . push ( this . metadata . headCommit ) ;
890
- await git ( args , { stdin : tagMessage , workDir : this . project . workDir } ) ;
915
+ await git ( args , { stdin : tagMessage , workDir : this . workDir } ) ;
891
916
}
892
917
893
918
protected async sendMBox ( mbox : string ) : Promise < void > {
894
- await git ( [ "send-mbox" ] , { stdin : mbox , workDir : this . project . workDir } ) ;
919
+ await git ( [ "send-mbox" ] , { stdin : mbox , workDir : this . workDir } ) ;
895
920
}
896
921
}
0 commit comments