@@ -38,54 +38,21 @@ logger
38
38
// Note: This is based on the gulp task found in the angular/angular repository
39
39
execSync ( 'git fetch origin' ) ;
40
40
41
- // Find the branch
42
- const branchRefs = { } ;
43
- for ( const name of config [ 'branches' ] ) {
44
- try {
45
- const output = execSync ( `git show-ref --hash ${ name } ` , { encoding : 'utf-8' } ) ;
46
- if ( output ) {
47
- branchRefs [ name ] = output . replace ( / \n / g, '' ) . trim ( ) ;
48
- }
49
- } catch ( e ) {
50
- // Ignore.
51
- }
52
- }
53
- logger . info ( `Found refs for branches:\n ${ Object . keys ( branchRefs ) . map ( key => {
54
- return `${ key } => ${ JSON . stringify ( branchRefs [ key ] ) } ` ;
55
- } ) . join ( '\n ' ) } `) ;
56
41
57
-
58
- const output = execSync ( 'git log --format="%H %s" --no-merges' , { encoding : 'utf-8' } ) ;
42
+ const output = execSync ( 'git log master.. --reverse --format="%H %s" --no-merges' , {
43
+ encoding : 'utf-8'
44
+ } ) ;
59
45
60
46
if ( output . length === 0 ) {
61
47
logger . warn ( 'There are zero new commits between this HEAD and master' ) ;
62
48
process . exit ( 0 ) ;
63
49
}
50
+ const commitsByLine = output . trim ( ) . split ( / \n / ) . map ( line => {
51
+ return line . trim ( ) . split ( ' ' ) . slice ( 1 ) . join ( ' ' ) ;
52
+ } ) ;
53
+ logger . info ( `Examining ${ commitsByLine . length } commit(s) between HEAD and master` ) ;
64
54
65
- const commitsByLine = [ ] ;
66
- let branch = null ;
67
-
68
- // Finding the closest branch marker.
69
- for ( const line of output . split ( / \n / ) ) {
70
- const [ hash , ...messageArray ] = line . split ( ' ' ) ;
71
- const message = messageArray . join ( ' ' ) ;
72
-
73
- const maybeBranch = Object . keys ( branchRefs ) . find ( branchName => branchRefs [ branchName ] === hash ) ;
74
- if ( maybeBranch ) {
75
- branch = maybeBranch ;
76
- break ;
77
- }
78
- commitsByLine . push ( message ) ;
79
- }
80
-
81
- if ( ! branch ) {
82
- logger . fatal ( 'Something wrong happened.' ) ;
83
- process . exit ( 1 ) ;
84
- }
85
-
86
- logger . info ( `Examining ${ commitsByLine . length } commit(s) between HEAD and ${ branch } ` ) ;
87
-
88
- const someCommitsInvalid = ! commitsByLine . every ( message => validateCommitMessage ( message , branch ) ) ;
55
+ const someCommitsInvalid = ! commitsByLine . every ( message => validateCommitMessage ( message ) ) ;
89
56
90
57
if ( someCommitsInvalid ) {
91
58
logger . error ( 'Please fix the failing commit messages before continuing...' ) ;
0 commit comments