Сроки проверки Nodegit не пройдены
Этот код должен сначала проверить, работает ли пользователь на master в git (если нет: попросить оформить заказ на ветку master). Если пользователь затем работает в главной ветке, код должен запрашивать извлечение (выборку и объединение) с удаленного узла.
Проблема в том, что он выполняет проверку после запроса пользователя на получение последней версии с пульта.
class GitManager
{
constructor(path, remoteName, belongBranch)
{
this.path = path;
this.remoteName = remoteName;
this.belongBranch = belongBranch;
this.mediator = new PromptAgent();
this.checkoutOptions = { checkoutStrategy: Git.Checkout.STRATEGY.FORCE };
this.gitLogic();
}
gitLogic()
{
Git.Repository.open(this.path).then( repository =>
{
this.askForCheckout(repository).then(() => this.askForPull(repository));
}
);
}
askForCheckout(repository)
{
repository.getCurrentBranch().then( reference =>
{
this.branchName = reference.shorthand();
this.remoteBranch = this.remoteName +'/' +this.branchName;
if (this.belongBranch !== this.branchName)
{
console.log("Currently you are NOT operating at " +this.belongBranch +".");
const checkoutMsg = "Would you like to checkout " +this.belongBranch +"?";
if (!this.mediator.binaryQuestion(checkoutMsg)) return this.valid = false;
this.repository.checkoutBranch(this.belongBranch, this.checkoutOptions);
return this.valid = true;
}
return this.valid = true;
}
);
}
askForPull()
{
repository.getCurrentBranch().then( reference =>
{
this.branchName = reference.shorthand();
this.remoteBranch = this.remoteName +'/' +this.branchName;
if (this.valid)
{
const pullMsg = "Pull latest version of " +this.branchName +" from remote?";
if (this.mediator.binaryQuestion(pullMsg))
{
this.repository.fetch(this.remoteName).then( () =>
{
this.repository.mergeBranches(this.remoteBranch);
}
);
return true;
}
}
else return false;
}
);
}
}
Спасибо за помощь!