chegele / AutoGitUpdate

Update node application from git repo.
65 stars 19 forks source link

AutoGitUpdate always update when the local is newer than the remote #7

Closed ttwrpz closed 2 years ago

ttwrpz commented 2 years ago

Hello, authors. I always face a problem that when I'm developing, AutoGitUpdate will always detect that it's not up to date. When I looked into the code, I found the line that always compares the local version and remote version is equal or not. I want to know to prevent this. Thank you. (P.S. Sorry for my grammar)

if (currentVersion == remoteVersion) return {upToDate: true, currentVersion};
return {upToDate: false, currentVersion, remoteVersion};
chegele commented 2 years ago

This was an intentional feature. The thought behind this decision was offering the ability to roll back in case there was a bug in a newer version. In that case, just push the old version to the branch being monitored.

I will think on potential work around for you and send another update soon. I do not believe a change to the base functionality would be wise as it could potentially impact applications that rely on it.

ttwrpz commented 2 years ago

Okay, I get it. Thank you so much for your response! ❤️

chegele commented 2 years ago

I believe the best solution for this scenario would be to utilize an environment variable to disable updates during development.

If you are using vscode to run/debug, you can add this to your launch config

"environment": [
    {
        "name": "noUpdate",
        "value": "true"
    }
]

From your project where calling Auto-Git-Update, you could do something similar to this.

const updater = new AutoGitUpdate(config);
const doUpdate = process.env.noUpdate != 'true';
if (update) updater.autoUpdate();
ttwrpz commented 2 years ago

Thank you ❤️