Skip to content

Instantly share code, notes, and snippets.

@disjukr
Last active December 16, 2015 16:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disjukr/5464839 to your computer and use it in GitHub Desktop.
Save disjukr/5464839 to your computer and use it in GitHub Desktop.
kill meta cycle
var fs = require('fs');
var path = require('path');
postMerge('.');
function postMerge(currentPath) {
var dir;
var mkdir;
var stat;
stat = fs.statSync(currentPath);
if (stat.isDirectory()) {
dir = fs.readdirSync(currentPath);
if (dir.length == 0) {
if (!fs.existsSync(currentPath + '.meta')) {
fs.rmdirSync(currentPath);
console.log('- ' + path.resolve(currentPath));
}
} else {
for (var i = 0; i < dir.length; ++i) {
postMerge(currentPath + '/' + dir[i]);
}
}
} else {
if (path.extname(currentPath) == '.meta') {
mkdir = currentPath.substring(0, currentPath.length - 5);
if (!fs.existsSync(mkdir)) {
fs.mkdirSync(mkdir);
console.log('+ ' + path.resolve(mkdir));
}
}
}
}

killMetaCycle.js

Unity3D makes .meta file all of each resource for version controlling. It makes .meta file of empty folder too. Empty folders are excluded when staging files on git.

If someone makes empty folders then unity makes corresponding meta file. And it removed when other worker pulled revision and turned on Unity3D. It causes nonsignificant diff logs cycle. I decided to call this "Meta Cycle".

killMetaCycle.js resolve the meta cycle.

do this when you pulled revision(or modify .git/hooks/post-merge):

node killMetaCycle.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment