@@ -6,11 +6,11 @@ $opts = parseOpts();
66$ changes = array ();
77
88if (! $ opts ['only-dev ' ]) {
9- $ changes ['changes ' ] = diff ('packages ' , $ opts ['from ' ], $ opts ['to ' ], $ opts ['path ' ], $ opts ['scm-type ' ]);
9+ $ changes ['changes ' ] = diff ('packages ' , $ opts ['from ' ], $ opts ['to ' ], $ opts ['path ' ], $ opts ['vcs ' ]);
1010}
1111
1212if (! $ opts ['only-prod ' ]) {
13- $ changes ['changes-dev ' ] = diff ('packages-dev ' , $ opts ['from ' ], $ opts ['to ' ], $ opts ['path ' ], $ opts ['scm-type ' ]);
13+ $ changes ['changes-dev ' ] = diff ('packages-dev ' , $ opts ['from ' ], $ opts ['to ' ], $ opts ['path ' ], $ opts ['vcs ' ]);
1414}
1515
1616if ($ opts ['json ' ]) {
@@ -40,17 +40,17 @@ foreach($changes as $k => $diff) {
4040 print tableize ($ table_titles [$ k ], $ diff , $ table_opts );
4141}
4242
43- function diff ($ key , $ from , $ to , $ base_path , $ scm ) {
43+ function diff ($ key , $ from , $ to , $ base_path , $ vcs ) {
4444
4545 $ pkgs = array ();
4646
47- $ data = load ($ from , $ base_path , $ scm );
47+ $ data = load ($ from , $ base_path , $ vcs );
4848
4949 foreach ($ data ->$ key as $ pkg ) {
5050 $ pkgs [$ pkg ->name ] = array (version ($ pkg ), 'REMOVED ' , '' );
5151 }
5252
53- $ data = load ($ to , $ base_path , $ scm );
53+ $ data = load ($ to , $ base_path , $ vcs );
5454
5555 foreach ($ data ->$ key as $ pkg ) {
5656 if (! array_key_exists ($ pkg ->name , $ pkgs )) {
@@ -150,7 +150,7 @@ function urlFormatterMd($url, $text) {
150150 return sprintf ('[%s](%s) ' , $ text , $ url );
151151}
152152
153- function load ($ fileish , $ base_path = '' , $ scm ) {
153+ function load ($ fileish , $ base_path = '' , $ vcs ) {
154154 $ orig = $ fileish ;
155155
156156 if (empty ($ base_path )) {
@@ -176,8 +176,8 @@ function load($fileish, $base_path = '', $scm) {
176176 return mustDecodeJson (file_get_contents ($ fileish ), $ fileish );
177177 }
178178
179- //try to find scm revision
180- if (strtolower ($ scm ) == 'git ' ){
179+ //try to find vcs revision
180+ if (strtolower ($ vcs ) == 'git ' ){
181181 if (strpos ($ orig , ': ' ) === false ) {
182182 $ fileish .= ': ' . $ base_path . 'composer.lock ' ;
183183 }
@@ -193,7 +193,7 @@ function load($fileish, $base_path = '', $scm) {
193193 return mustDecodeJson (implode ("\n" , $ lines ), $ fileish );
194194 }
195195
196- elseif (strtolower ($ scm ) == 'svn ' ){
196+ elseif (strtolower ($ vcs ) == 'svn ' ){
197197 if (strpos ($ orig , '@ ' ) === false ) {
198198 $ fileish = $ base_path . 'composer.lock@ ' .$ fileish ;
199199 }
@@ -206,7 +206,7 @@ function load($fileish, $base_path = '', $scm) {
206206 return mustDecodeJson (implode ("\n" , $ lines ), $ fileish );
207207 }
208208
209- error_log ("Error: unhandled SCM $ scm " );
209+ error_log ("Error: unhandled VCS $ vcs " );
210210 exit (1 );
211211}
212212
@@ -297,7 +297,7 @@ function formatCompareDrupal($url, $from, $to) {
297297}
298298
299299function parseOpts () {
300- $ given = getopt ('hp: ' , array ('path: ' , 'from: ' , 'to: ' , 'md ' , 'json ' , 'pretty ' , 'no-links ' , 'only-prod ' , 'only-dev ' , 'help ' , 'scm : ' ));
300+ $ given = getopt ('hp: ' , array ('path: ' , 'from: ' , 'to: ' , 'md ' , 'json ' , 'pretty ' , 'no-links ' , 'only-prod ' , 'only-dev ' , 'help ' , 'vcs : ' ));
301301
302302 foreach (array ('help ' => 'h ' , 'path ' => 'p ' ) as $ long => $ short ) {
303303 if (array_key_exists ($ short , $ given )) {
@@ -322,11 +322,11 @@ function parseOpts() {
322322 'no-links ' => array_key_exists ('no-links ' , $ given ),
323323 'only-prod ' => array_key_exists ('only-prod ' , $ given ),
324324 'only-dev ' => array_key_exists ('only-dev ' , $ given ),
325- 'scm-type ' => array_key_exists ('scm ' , $ given ) ? $ given ['scm ' ] : scmDetect ($ path ),
325+ 'vcs ' => array_key_exists ('vcs ' , $ given ) ? $ given ['vcs ' ] : vcsDetect ($ path ),
326326 );
327327}
328328
329- function scmDetect ($ base_path ){
329+ function vcsDetect ($ base_path ){
330330 if (empty ($ base_path )) {
331331 $ base_path = '. ' . DIRECTORY_SEPARATOR ;
332332 } else {
@@ -362,6 +362,7 @@ Options:
362362 --no-links Don't include Compare links in plain text or any links in markdown
363363 --only-prod Only include changes from `packages`
364364 --only-dev Only include changes from `packages-dev`
365+ --vcs Force vcs (git, svn, ...). Default auto-detect from path
365366
366367EOF ;
367368
0 commit comments