Open ebuzzz opened 8 years ago
It's been a while since I used this to deploy a brand new project (most of the ones deploying have history going back quite a while now), so that may well be the case.
Does it give you an error when running the deploy task? I'm assuming it's failing on git clone
, but I want to be sure.
Having the same issue (taskname = package). This is the error log:
[12:04:32] git clone: warning: Could not find remote branch repo/updates to clone.
[12:04:32] git clone: fatal: Remote branch repo/updates not found in upstream origin
[12:04:32] 'package' errored after 1.27 s
[12:04:32] Error in plugin 'gulp-deploy-git'
Message: git clone exited with code 128
Could you post the relevant parts of the gulp file? If possible, could you also include the results of git branch -r
?
Also, this is a brand new repository you're deploying to? There are no branches?
Hi, thanks for checking in on short notice.
Gulptask:
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({ lazy: true });
function pack() {
// get branch name
$.git.revParse({ args: '--abbrev-ref HEAD' }, function (err, branch) {
return gulp.src('dist/scripts/**/*', { read: false })
.pipe($.deployGit({
repository: 'http://linktorepository',
branches: [branch],
remoteBranch: [branch],
verbose: true
}));
});
}
gulp.task('package', pack);
The target branch is indeed a brand new repo, with only a (empty) master branch.
Okay, seems it doesn't deal too well with non-existing branches. Tagging that to be fixed in 1.0.0. Until then, manually create the remote branch and it should work fine.
Clone the repository (with the empty master) and create a placeholder file:
$ git checkout -b branch
$ touch PLACEHOLDER
$ git commit -a -m "Initial commit"
$ git push -u origin branch
The placeholder file will be automatically deleted when you run a deploy.
@zhevron cool, thanks for addressing this. Looking forward to the 1.0.0 release.
With any luck, I should have a version that addresses this prior to the 1.0.0 release out this week. I'm currently rewriting most of the code to make it more...maintainable for the future.
@zhevron hi, any progress on this? thanks!
I have solved this by first running:
function createBranchOnDeployTarget(cb) {
$.git.exec({ args: 'ls-remote ' + deployTarget+ ' ' + branchName, quiet: true }, function (err1, stdout) {
if (stdout === '') {
$.git.exec({ args: 'push ' + deployTarget + ' origin:refs/heads/' + branchName, quiet: true }, function (err2) {
if (err2) {
return cb($.util.log($.util.colors.red(err2)));
}
});
} else if (err1) {
return cb($.util.log($.util.colors.red(err1)));
}
return cb();
});
}
I've setup a bare repository on my production server. When I try to deploy the code, the first step is to checkout the remote branch. But at the time, there is no remove branch.
Is this something that should be done manually the first time, or am I missing a step in the process?