File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,34 @@ const runCommand = (command, force) => {
2828 }
2929} ;
3030
31+ const checkBranchSync = ( ) => {
32+ console . log ( "Checking if local master branch is in sync with origin..." ) ;
33+
34+ if ( isDryRun ) {
35+ console . log ( "[Dry Run] Checking sync..." ) ;
36+ } else {
37+ try {
38+ // Fetch the latest changes from the remote repository
39+ runCommand ( "git fetch origin" ) ;
40+
41+ // Get the commit hashes of the local and remote master branches
42+ const localMaster = runCommand ( "git rev-parse master" ) . trim ( ) ;
43+ const remoteMaster = runCommand ( "git rev-parse origin/master" ) . trim ( ) ;
44+
45+ if ( localMaster !== remoteMaster ) {
46+ console . error (
47+ "Local master branch is not in sync with origin. Please pull the latest changes before proceeding."
48+ ) ;
49+ process . exit ( 1 ) ;
50+ }
51+ } catch ( error ) {
52+ console . error ( "Error checking branch sync status." ) ;
53+ console . error ( error ) ;
54+ process . exit ( 1 ) ;
55+ }
56+ }
57+ } ;
58+
3159const getCurrentVersion = ( ) => {
3260 console . log ( "Getting current version..." ) ;
3361 const packageJson = JSON . parse ( readFileSync ( "./package.json" , "utf-8" ) ) ;
@@ -153,6 +181,9 @@ const createGithubRelease = async (version, changelogContent) => {
153181
154182const main = async ( ) => {
155183 console . log ( "Starting release process..." ) ;
184+
185+ checkBranchSync ( ) ;
186+
156187 checkUncommittedChanges ( ) ;
157188
158189 const changelogContent = await generateChangelog ( ) ;
You can’t perform that action at this time.
0 commit comments