Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(var key in file.revReferenceFiles) is no order #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions revisioner.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,27 +288,32 @@ var Revisioner = (function () {
var hash = file.revHashOriginal;

stack.push(file);


var hashArray = [];
// Resolve hash for child references
if (Object.keys(file.revReferenceFiles).length > 0) {


hashArray.push(hash);
for (var key in file.revReferenceFiles) {

// Prevent infinite loops caused by circular references, don't recurse if we've already encountered this file
if (stack.indexOf(file.revReferenceFiles[key]) === -1) {
hash += this.calculateHash(file.revReferenceFiles[key], stack);
hashArray.push(this.calculateHash(file.revReferenceFiles[key], stack));
}

}

// This file's hash should change if any of its references will be prefixed.
if (this.options.prefix &&
Object.keys(file.referenceGroupsContainer.absolute).length) {
hash += this.options.prefix;
hashArray.push(this.options.prefix);
}


hashArray.sort(function(a, b){
return a > b;
});
// Consolidate many hashes into one
hash = this.Tool.md5(hash);
hash = this.Tool.md5(hashArray.join(""));

}

Expand Down