Skip to content

Commit b47d5e5

Browse files
committed
fix(publish): hopefully fix pushing of commits
1 parent c9b5e57 commit b47d5e5

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

lib/git.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,13 @@ async function push (origin, branch, execaOpts) {
3535
await execa('git', ['push', '--follow-tags', origin, `HEAD:${branch}`], execaOpts)
3636
}
3737

38-
/**
39-
* Merges the master branch into the dev branch. The devBranch must be specified
40-
* in the options for this to work.
41-
*/
42-
async function mergeMasterIntoDev (context) {
38+
async function configureGit (context) {
4339
const {env, cwd, logger, options} = context
4440
const execaOpts = {env, cwd}
45-
const {branch, devBranch, repositoryUrl} = options
46-
47-
logger.log('Merging master branch into dev branch')
4841

4942
// fetch all branches because Travis doesn't do it for us
5043
// code copied from https://stackoverflow.com/a/44036486/269834
44+
logger.log('configuring git')
5145
await execa(
5246
'git',
5347
[
@@ -60,24 +54,41 @@ async function mergeMasterIntoDev (context) {
6054
)
6155

6256
// fetch everything
57+
logger.log('fetching branches')
6358
await execa('git', ['fetch'], execaOpts)
6459

65-
// checkout master branch
66-
// this is done because otherwise the commit seems to be the one just before
67-
// the snapshot release
68-
await execa('git', ['checkout', branch], execaOpts)
60+
// checkout master and pull latest
61+
logger.log('checking out release branch')
62+
await execa('git', ['checkout', options.branch], execaOpts)
6963

70-
// pull changes into master
64+
logger.log('pulling')
7165
await execa('git', ['pull'], execaOpts)
66+
}
67+
68+
/**
69+
* Merges the master branch into the dev branch. The devBranch must be specified
70+
* in the options for this to work.
71+
*/
72+
async function mergeMasterIntoDev (context) {
73+
const {env, cwd, logger, options} = context
74+
const execaOpts = {env, cwd}
75+
const {branch, devBranch, repositoryUrl} = options
76+
77+
logger.log('Merging master branch into dev branch')
7278

7379
// checkout dev branch
80+
logger.log('checking out dev branch')
7481
await execa('git', ['checkout', devBranch], execaOpts)
7582

7683
// merge
84+
logger.log('merging release branch into dev branch')
7785
await execa('git', ['merge', branch], execaOpts)
7886

7987
// push
88+
logger.log('pushing dev branch')
8089
await push(repositoryUrl, devBranch, execaOpts)
90+
91+
logger.log('merge and push successful!')
8192
}
8293

8394
/**
@@ -107,9 +118,12 @@ async function saveChangesToPomXml (context, versionStr) {
107118

108119
logger.log('pushing changes')
109120
await push(repositoryUrl, branch, execaOpts)
121+
122+
logger.log('changes pushed')
110123
}
111124

112125
module.exports = {
126+
configureGit,
113127
mergeMasterIntoDev,
114128
saveChangesToPomXml
115129
}

lib/publish.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {mergeMasterIntoDev, saveChangesToPomXml} = require('./git')
1+
const {configureGit, mergeMasterIntoDev, saveChangesToPomXml} = require('./git')
22
const {updateVersionInPomXml, deploy} = require('./maven')
33

44
/**
@@ -13,6 +13,9 @@ module.exports = async function publish (pluginConfig, context) {
1313

1414
// special logic to do some extra Conveyal-specific tasks
1515
if (options.useConveyalWorkflow) {
16+
// do some extra configuration to allow pushing more than 1 commit
17+
await configureGit(context)
18+
1619
// bump to snapshot version
1720
const nextSnapshotVersion = nextRelease.version.split('.').map(s => parseInt(s, 10))
1821
nextSnapshotVersion[2] += 1

0 commit comments

Comments
 (0)