Authored by xuqi

switch branch

... ... @@ -47,7 +47,7 @@ class Build {
this._prebuild();
this.startTime = (new Date()).getTime();
return this._cloneCode(this.branch).then(() => {
let pkg = require(path.join(this.codePath, 'package.json'));
let pkg = require(path.join(self.codePath, 'package.json'));
// set version
self.version = pkg.version;
self.pkgName = pkg.name;
... ... @@ -108,7 +108,7 @@ class Build {
if(sh.ls(config.codeDir).indexOf(this.project.name) > -1) {
update = true;
syncCodeScript = `git pull origin ${self.branch}`;
syncCodeScript = `git fetch && git checkout ${self.branch} && git reset --hard origin/${self.branch} && git pull origin ${self.branch}`;
} else {
syncCodeScript = `git submodule add -f ${this.project.gitlab}`;
}
... ... @@ -127,7 +127,7 @@ class Build {
// 回到上级目录更新
let child = sh.exec(syncCodeScript, {
silent: self.silent,
// silent: self.silent,
async: true
});
... ...
... ... @@ -133,7 +133,7 @@ const p = {
project_build: async(ctx, next) => {
let pid = ctx.params.pid;
let env = 'production';
let branch = 'master';
let branch = ctx.request.body.branch;
let p = await Project.findById(pid);
let build = new Build(p);
... ...
... ... @@ -23,7 +23,7 @@
<a href="" class="tooltips panel-minimize"><i class="fa fa-minus"></i></a>
</div>
<h4 class="panel-title">Static Deploy For {{project.subname}}</h4>
<p>分支:<code>Matser</code></p>
<p>默认分支:<code>matser</code></p>
</div>
<div class="panel-body">
<table id="table-production" class="table table-striped table-bordered building-table">
... ... @@ -125,10 +125,19 @@
}
$('.build-btn').click(function() {
$.post('/projects/build/{{project._id}}', function(ret) {
if (ret.code == 200) {
tables.ajax.reload();
}
var i = layer.prompt({
title: '请输入需要构建的分支,默认为master',
value: 'master'
}, function(branch) {
branch = branch || 'master';
$.post('/projects/build/{{project._id}}', {
branch: branch
}, function(ret) {
if (ret.code == 200) {
tables.ajax.reload();
layer.close(i);
}
});
});
});
... ...