Skip to content

Commit

Permalink
fix(publish): hopefully fix pushing of commits
Browse files Browse the repository at this point in the history
  • Loading branch information
evansiroky committed Nov 29, 2018
1 parent c9b5e57 commit b47d5e5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
40 changes: 27 additions & 13 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,13 @@ async function push (origin, branch, execaOpts) {
await execa('git', ['push', '--follow-tags', origin, `HEAD:${branch}`], execaOpts)
}

/**
* Merges the master branch into the dev branch. The devBranch must be specified
* in the options for this to work.
*/
async function mergeMasterIntoDev (context) {
async function configureGit (context) {
const {env, cwd, logger, options} = context
const execaOpts = {env, cwd}
const {branch, devBranch, repositoryUrl} = options

logger.log('Merging master branch into dev branch')

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

// fetch everything
logger.log('fetching branches')
await execa('git', ['fetch'], execaOpts)

// checkout master branch
// this is done because otherwise the commit seems to be the one just before
// the snapshot release
await execa('git', ['checkout', branch], execaOpts)
// checkout master and pull latest
logger.log('checking out release branch')
await execa('git', ['checkout', options.branch], execaOpts)

// pull changes into master
logger.log('pulling')
await execa('git', ['pull'], execaOpts)
}

/**
* Merges the master branch into the dev branch. The devBranch must be specified
* in the options for this to work.
*/
async function mergeMasterIntoDev (context) {
const {env, cwd, logger, options} = context
const execaOpts = {env, cwd}
const {branch, devBranch, repositoryUrl} = options

logger.log('Merging master branch into dev branch')

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

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

// push
logger.log('pushing dev branch')
await push(repositoryUrl, devBranch, execaOpts)

logger.log('merge and push successful!')
}

/**
Expand Down Expand Up @@ -107,9 +118,12 @@ async function saveChangesToPomXml (context, versionStr) {

logger.log('pushing changes')
await push(repositoryUrl, branch, execaOpts)

logger.log('changes pushed')
}

module.exports = {
configureGit,
mergeMasterIntoDev,
saveChangesToPomXml
}
5 changes: 4 additions & 1 deletion lib/publish.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {mergeMasterIntoDev, saveChangesToPomXml} = require('./git')
const {configureGit, mergeMasterIntoDev, saveChangesToPomXml} = require('./git')
const {updateVersionInPomXml, deploy} = require('./maven')

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

// special logic to do some extra Conveyal-specific tasks
if (options.useConveyalWorkflow) {
// do some extra configuration to allow pushing more than 1 commit
await configureGit(context)

// bump to snapshot version
const nextSnapshotVersion = nextRelease.version.split('.').map(s => parseInt(s, 10))
nextSnapshotVersion[2] += 1
Expand Down

0 comments on commit b47d5e5

Please sign in to comment.