I'm using nodegit and I can't figure out how to detect whether the there has been changes to commit.
Currently, I'm committing when an external event happens, but I don't know if this will cause a real difference in the files. I don't check whether the commit is empty before pushing, which led me to end up with lots of empty commits, I'd like to avoid that.
When doing it manually, I usually run a git status
to check whether there were changes to commit, I was thinking about doing something similar here, but can't figure out how. (here is the documentation)
console.log('committing...');
const commitResult = await commitFile(`schema.json`, schemaAsString, `${appName} (${appId})`);
const statuses = await repo.getStatus();
console.log('getStatus status', statuses);
console.log('getStatus status', statuses[0].status());
console.log('getStatus isModified', statuses[0].isModified());
console.log('getStatus path', statuses[0].path());
console.log('getStatus statusBit', statuses[0].statusBit());
console.log('pushing...');
const pushResult = await push(repo);
console.log('pushResult', pushResult);