This repository was archived by the owner on Jan 10, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +60
-14
lines changed
Expand file tree Collapse file tree 9 files changed +60
-14
lines changed Original file line number Diff line number Diff line change 1+ var execSync = require ( "child_process" ) . execSync ;
2+
3+ module . exports = {
4+
5+ branch : function ( ) {
6+ return execSync ( "git rev-parse --abbrev-ref HEAD || hg branch" ) . toString ( ) . trim ( ) ;
7+ } ,
8+
9+ head : function ( ) {
10+ return execSync ( "git log -1 --pretty=%H || hg id -i --debug | tr -d '+'" ) . toString ( ) . trim ( ) ;
11+ }
12+
13+ } ;
Original file line number Diff line number Diff line change 1- var execSync = require ( 'child_process' ) . execSync ;
1+ var git = require ( '../git' ) ;
22
33module . exports = {
44
@@ -11,7 +11,7 @@ module.exports = {
1111 return {
1212 service : 'drone.io' ,
1313 build : process . env . DRONE_BUILD_NUMBER ,
14- commit : execSync ( " git rev-parse HEAD || hg id -i --debug | tr -d '+'" ) . toString ( ) . trim ( ) ,
14+ commit : git . head ( ) ,
1515 build_url : process . env . DRONE_BUILD_URL ,
1616 branch : process . env . DRONE_BRANCH ,
1717 root : process . env . DRONE_BUILD_DIR
Original file line number Diff line number Diff line change 1+ var git = require ( '../git' ) ;
2+
13module . exports = {
24
35 detect : function ( ) {
@@ -8,12 +10,12 @@ module.exports = {
810 console . log ( ' Jenkins CI Detected' ) ;
911 return {
1012 service : 'jenkins' ,
11- commit : process . env . ghprbActualCommit || process . env . GIT_COMMIT ,
12- branch : process . env . ghprbSourceBranch || process . env . GIT_BRANCH ,
13+ commit : process . env . ghprbActualCommit || process . env . GIT_COMMIT || git . head ( ) ,
14+ branch : process . env . ghprbSourceBranch || process . env . GIT_BRANCH || process . env . BRANCH_NAME ,
1315 build : process . env . BUILD_NUMBER ,
1416 build_url : process . env . BUILD_URL ,
1517 root : process . env . WORKSPACE ,
16- pr : process . env . ghprbPullId
18+ pr : process . env . ghprbPullId || process . env . CHANGE_ID
1719 } ;
1820 }
1921
Original file line number Diff line number Diff line change 1- var execSync = require ( 'child_process' ) . execSync ;
1+ var git = require ( '../git' )
22
33module . exports = {
44
55 configuration : function ( ) {
66 console . log ( ' No CI Detected. Using git/mercurial' ) ;
7- var branch = execSync ( " git rev-parse --abbrev-ref HEAD || hg branch" ) . toString ( ) . trim ( ) ;
7+ var branch = git . branch ( ) ;
88 if ( branch === 'HEAD' ) {
99 branch = 'master' ;
1010 }
11- var head = execSync ( " git rev-parse HEAD || hg id -i --debug | tr -d '+'" ) . toString ( ) . trim ( ) ;
11+ var head = git . head ( ) ;
1212 return {
1313 commit : head ,
1414 branch : branch
Original file line number Diff line number Diff line change 11var detect = require ( "../lib/detect" ) ;
2- var execSync = require ( 'child_process' ) . execSync ;
2+ var git = require ( "../lib/git" ) ;
33
44describe ( "Codecov" , function ( ) {
55
@@ -13,7 +13,7 @@ describe("Codecov", function(){
1313
1414 it ( "can select local git service if no service is found" , function ( ) {
1515 expect ( detect ( ) . commit ) . to . match ( / ^ \w { 40 } $ / ) ;
16- expect ( detect ( ) . commit ) . to . eql ( execSync ( " git rev-parse HEAD || hg id -i --debug | tr -d '+'" ) . toString ( ) . trim ( ) ) ;
16+ expect ( detect ( ) . commit ) . to . eql ( git . head ( ) ) ;
1717 } ) ;
1818
1919} ) ;
Original file line number Diff line number Diff line change 1+ var git = require ( "../lib/git" ) ;
2+ var execSync = require ( "child_process" ) . execSync ;
3+
4+ describe ( "Git" , function ( ) {
5+
6+ it ( "can get the branch" , function ( ) {
7+ expect ( git . branch ( ) ) . to . eql ( execSync ( "git rev-parse --abbrev-ref HEAD || hg branch" ) . toString ( ) . trim ( ) ) ;
8+ } ) ;
9+
10+ it ( "can get the head" , function ( ) {
11+ expect ( git . head ( ) ) . to . eql ( execSync ( "git log -1 --pretty=%H || hg id -i --debug | tr -d '+'" ) . toString ( ) . trim ( ) ) ;
12+ } ) ;
13+
14+ } ) ;
Original file line number Diff line number Diff line change 11var drone = require ( "../../lib/services/drone" ) ;
2- var execSync = require ( 'child_process' ) . execSync ;
2+ var git = require ( "../../lib/git" ) ;
33
44describe ( "Drone.io CI Provider" , function ( ) {
55
@@ -15,7 +15,7 @@ describe("Drone.io CI Provider", function(){
1515 process . env . DRONE_BUILD_DIR = '/' ;
1616 expect ( drone . configuration ( ) ) . to . eql ( {
1717 service : 'drone.io' ,
18- commit : execSync ( " git rev-parse HEAD || hg id -i --debug | tr -d '+'" ) . toString ( ) . trim ( ) ,
18+ commit : git . head ( ) ,
1919 build : '1234' ,
2020 root : '/' ,
2121 branch : 'master' ,
Original file line number Diff line number Diff line change 11var jenkins = require ( "../../lib/services/jenkins" ) ;
2+ var git = require ( "../../lib/git" ) ;
23
34describe ( "Jenkins CI Provider" , function ( ) {
45
@@ -24,6 +25,24 @@ describe("Jenkins CI Provider", function(){
2425 } ) ;
2526 } ) ;
2627
28+ it ( "can get service env info when using Blue Ocean" , function ( ) {
29+ delete process . env . GIT_COMMIT ;
30+ delete process . env . GIT_BRANCH ;
31+ process . env . BUILD_NUMBER = '1234' ;
32+ process . env . BUILD_URL = 'http://asdf/' ;
33+ process . env . BRANCH_NAME = 'master' ;
34+ process . env . WORKSPACE = '/' ;
35+ expect ( jenkins . configuration ( ) ) . to . eql ( {
36+ service : 'jenkins' ,
37+ build_url : 'http://asdf/' ,
38+ build : '1234' ,
39+ root : '/' ,
40+ commit : git . head ( ) ,
41+ pr : undefined ,
42+ branch : 'master'
43+ } ) ;
44+ } )
45+
2746 it ( "github pull request env variables win out over jenkins variables" , function ( ) {
2847 process . env . BUILD_NUMBER = '1234' ;
2948 process . env . BUILD_URL = 'http://asdf/' ;
Original file line number Diff line number Diff line change 11var fs = require ( 'fs' ) ;
22var codecov = require ( '../lib/codecov' ) ;
33var offlineErrors = require ( '../lib/offline' ) ;
4- var execSync = require ( 'child_process' ) . execSync ;
5-
64
75describe ( "Codecov" , function ( ) {
86 it ( "can get upload to v2" , function ( done ) {
You can’t perform that action at this time.
0 commit comments