Skip to content

Commit

Permalink
Add support for git push <repo> with "src.pushRepo" option (resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Sep 20, 2015
1 parent 76b05e9 commit 335b830
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ Options:
"buildCommand": false,
"changelogCommand": "git log --pretty=format:'* %s (%h)' [REV_RANGE]",
"requireCleanWorkingDir": false,
"src": {
"pushRepo": null
},
"dist": {
"repo": false,
"stageDir": ".stage",
Expand All @@ -130,6 +133,11 @@ Options:
}
```

Notes:

* If `src.pushRepo` has a falsey value, just `git push` is used. Otherwise, it's the url or name of a remote in `git push <src.pushRepo>`.
* If `dist.pkgFiles` has a falsey value, it will take the value of `pkgFiles`.

### Distribution Repository

Some projects use a special distribution repository. There might be multiple reasons to do.
Expand Down
3 changes: 3 additions & 0 deletions conf/release.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"buildCommand": false,
"changelogCommand": "git log --pretty=format:'* %s (%h)' [REV_RANGE]",
"requireCleanWorkingDir": false,
"src": {
"pushRepo": null
},
"dist": {
"repo": false,
"stageDir": ".stage",
Expand Down
13 changes: 8 additions & 5 deletions lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,26 @@ function getLatestTag() {
});
}

function push(repository) {
function push(remoteUrl, pushUrl) {
tracker._track('git', 'push');
return run('git', 'push').catch(function(err) {
var repository = pushUrl || '';
return run('git', 'push', repository).catch(function(err) {
log.error('Please make sure an upstream remote repository is configured for the current branch. Example commands:\n' +
'git remote add origin ' + repository + '\n' +
'git remote add origin ' + remoteUrl + '\n' +
'git push --set-upstream origin master');
throw new Error(err);
})
}

function pushTags() {
function pushTags(pushUrl) {
tracker._track('git', 'push-tags');
var repository = pushUrl || '';
return run(
'git',
'push',
'--tags',
config.isForce() ? '--force' : ''
config.isForce() ? '--force' : '',
repository
);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ function getSrcRepoTasks(options) {
stage: git.stage.bind(null, options.pkgFiles),
stageDir: isStageBuildDir ? git.stageDir.bind(null, options.dist.baseDir) : noop,
hasChanges: git.hasChanges.bind(null, 'src'),
push: git.push.bind(null, options.remoteUrl, options.src.pushRepo),
pushTags: git.pushTags.bind(null, options.src.pushRepo),
release: options.github.release ? git.release.bind(null, options, options.remoteUrl) : noop,
publish: isPublish ? shell.npmPublish.bind(null, options.npm.publishPath, options.npm.tag) : noop
});
Expand Down

0 comments on commit 335b830

Please sign in to comment.