You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now if you you set -b to something that isn't a tagged commit, it will clone, but it will fail to re-validate when you re-run the postinstall script because it fails const output = spawnSync('git', ['describe', '--tags'], { ....
To resolve this, we need to recognize when -b is set to something that isn't a tagged commit and instead of doing the git describe, we do a git fetch, git status or git log instead to see if there are new commits, then do a git pull instead of checking to see if we need to re-clone.
e.g.
const{ exec }=require('child_process');functioncheckForNewCommits(){// Fetch the latest changes from the remote repositoryexec('git fetch',(fetchError,fetchStdout,fetchStderr)=>{if(fetchError){console.error(`Error fetching from remote: ${fetchError}`);return;}// Compare the local branch with the remote branchexec('git status -uno',(statusError,statusStdout,statusStderr)=>{if(statusError){console.error(`Error checking status: ${statusError}`);return;}// Check if there are new commitsif(statusStdout.includes('Your branch is behind')){console.log('There are new commits available.');}else{console.log('Your branch is up to date.');}});});}// Example usagecheckForNewCommits();
If this is successfully implemented, we could probably reuse the logic elsewhere as well to prevent re-cloning in situations where it is not necessary. For example, if you have -b 1.0.0 that is a tagged commit on main, then you update it to -b 1.0.1 which is a new tagged commit also on main, it would be nice if instead of re-cloning, it simply does a fetch and pull, but only pull the commits up to the new tag via git checkout tags/1.0.1 or whatever.
e.g.
const{ exec }=require('child_process');functionpullUpToTag(tag){// Fetch all tags from the remote repositoryexec('git fetch --tags',(fetchError,fetchStdout,fetchStderr)=>{if(fetchError){console.error(`Error fetching tags: ${fetchError}`);return;}// Checkout the specific tagexec(`git checkout tags/${tag}`,(checkoutError,checkoutStdout,checkoutStderr)=>{if(checkoutError){console.error(`Error checking out tag ${tag}: ${checkoutError}`);return;}console.log(`Successfully checked out tag ${tag}`);});});}// Example usagepullUpToTag('1.0.1');
The text was updated successfully, but these errors were encountered:
Right now if you you set
-b
to something that isn't a tagged commit, it will clone, but it will fail to re-validate when you re-run the postinstall script because it failsconst output = spawnSync('git', ['describe', '--tags'], { ...
.To resolve this, we need to recognize when
-b
is set to something that isn't a tagged commit and instead of doing thegit describe
, we do agit fetch
,git status
orgit log
instead to see if there are new commits, then do agit pull
instead of checking to see if we need to re-clone.e.g.
If this is successfully implemented, we could probably reuse the logic elsewhere as well to prevent re-cloning in situations where it is not necessary. For example, if you have
-b 1.0.0
that is a tagged commit onmain
, then you update it to-b 1.0.1
which is a new tagged commit also on main, it would be nice if instead of re-cloning, it simply does a fetch and pull, but only pull the commits up to the new tag viagit checkout tags/1.0.1
or whatever.e.g.
The text was updated successfully, but these errors were encountered: