Closed ghost closed 7 years ago
@haradayoshitsuguis I don't believe this actually fixes the problem, there is code that depends on this method executing synchronously. How about giving the code below a go and letting me know if it works. If it works for you I'll explore it further and update the method. The following code makes this logic iterative vs recursive:
var getAllReachableCommits = function(startingSha, store) {
var shasToExplore = [startingSha];
while(shasToExplore.length > 0) {
sha = shasToExplore.shift();
if (!commitsBySha[sha]) continue;
store[sha] = true;
commitsBySha[sha].parents.forEach(function(parent) {
if (directDescendents[parent.sha]) return;
if (store[parent.sha]) return; // don't revist commits we've explored
shasToExplore.push(parent.sha);
})
}
}
@lalitkapoor thank you for your reply ! I tryed your code. but is's not working.
a processing don't exit while loop Infinitely. I think shasToExplore.push(parent.sha)
is shasToExplore.pop(parent.sha)
is it correct ?
when I did that, working successfully.
@haradayoshitsuguis no, that’s not correct. It needs to be push. Can you add a console.log below the while loop that prints out shasToExplore and can you share that output? It should eventually terminate...it shouldn’t be looping through things it has already explored.
Also log to see how many times getAllReachableCommits is being called, maybe it is just taking Long on your repo for some reason, would be good to understand why
@lalitkapoor hello, I tried again with log output. (as below)
var getAllReachableCommits = function(startingSha, store) {
console.log('start getAllReachableCommits--------------');
var shasToExplore = [startingSha];
while(shasToExplore.length > 0) {
console.log('shasToExplore.length: ');
console.log(shasToExplore.length);
console.log('shasToExplore: ');
console.log(shasToExplore);
sha = shasToExplore.shift();
if (!commitsBySha[sha]) continue;
store[sha] = true;
commitsBySha[sha].parents.forEach(function(parent) {
if (directDescendents[parent.sha]) return;
if (store[parent.sha]) return; // don't revist commits we've explored
shasToExplore.push(parent.sha);
})
}
};
paste log on my gist. https://gist.github.com/haradayoshitsuguis/b7c963080a16f02263adeaf650a3fbaf#file-getallreachablecommits_failed
Then I found while loop is not Infinitely, but It did not end even after 20 minutes passed.
I thought it's my repo fault. (I tryed on another repo. the code you gave this time worked fine.)
this is not your problem. do not need to fix. sorry...
great! Good luck! I'll close this PR. Feel free to reach back out if you find a bug in github-changes. Thanks!
Thanks @lalitkapoor ! I will continue to use github-changes. keep in touch.
hello. I met a problem of stackover flow as blow.
then, I like to suggest stackover flow workaround like this PR.