Skip to content
This repository has been archived by the owner on Jan 13, 2018. It is now read-only.

Commit

Permalink
Merge branch 'i-335'
Browse files Browse the repository at this point in the history
0.5.29
  • Loading branch information
Vladimir Alaev committed Mar 25, 2013
2 parents 85703c7 + 4c2393a commit 5386f85
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
bem-tools changelog
===================
25.03.2013, Version 0.5.29 (stable)
-----------------------------------

- bem make: don't update git library form upstream when working copy state satisfies to configured one. git update commands chain altered (no git reset for now) (Closes #335)

20.03.2013, Version 0.5.27 (stable)
-----------------------------------

Expand Down
66 changes: 65 additions & 1 deletion lib/nodes/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,71 @@ registry.decl(GitLibraryNodeName, ScmLibraryNodeName, /** @lends GitLibraryNode.
},

getUpdateCmd: function(url, target) {
return UTIL.format('cd %s && git fetch origin && git reset --hard %s', target, this.treeish || 'origin/' + this.branch);
var onBranch = !this.treeish;

return UTIL.format('cd %s && git fetch origin %s git checkout %s %s', target,
onBranch? ('&& git branch ' + this.branch + '; '): ' && ',
this.treeish || this.branch,
onBranch? '&& git rebase origin/' + this.branch: '');
},

isValid: function() {

var _this = this,
path = PATH.resolve(this.root, this.target);

return QFS.exists(path)
.then(function(exists) {
return exists && _this.getInfo(path)
.then(function(info) {
var head = info['HEAD'],
wanted = _this.treeish || _this.branch;

LOGGER.verbose('HEAD is at ' + head + ' wanted is ' + wanted);

// head is at configured hash
if (wanted === head) return true;

var resolves = 'refs/heads/' + wanted;
if (info[resolves] !== head) resolves = 'refs/tags/' + wanted;
if (info[resolves] !== head) resolves = '';

if (resolves) LOGGER.fverbose('%s resolves to %s', head, resolves)
else LOGGER.fverbose('%s does not resolve to %s', head, wanted);

return !!resolves;
});
});

},

getInfo: function(path) {

var _this = this,
cmd = UTIL.format('cd %s && git show-ref --head', path),
d = Q.defer();

this.log(cmd);

CP.exec(cmd, function(err, stdout, stderr) {
stderr && _this.log(stderr);

if (err) return d.reject(err);

d.resolve(_this._parseInfo(stdout));
});

return d.promise;
},

_parseInfo: function(stdout) {
var refs = {};
stdout.split('\n').forEach(function(line) {
var ref = line.split(' ');
refs[ref[1]] = ref[0];
})

return refs;
}

});
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bem",
"description": "BEM Tools",
"version": "0.5.28",
"version": "0.5.29",
"homepage": "http://github.com/bem/bem-tools",
"author": "Sergey Berezhnoy <veged@mail.ru> (http://github.com/veged)",
"maintainers": [
Expand Down

0 comments on commit 5386f85

Please sign in to comment.