Parcourir la source

fix(git): reset hard on remote branch before pulling

Nicolas Meienberger il y a 1 an
Parent
commit
3959fd8a1f
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 5 1
      packages/cli/src/executors/repo/repo.executors.ts

+ 5 - 1
packages/cli/src/executors/repo/repo.executors.ts

@@ -88,8 +88,12 @@ export class RepoExecutors {
         this.logger.info(`stdout: ${stdout}`);
       });
 
+      const currentBranch = await execAsync(`git -C ${repoPath} rev-parse --abbrev-ref HEAD`).then(({ stdout }) => {
+        return stdout.trim();
+      });
+
       // reset hard
-      await execAsync(`git -C ${repoPath} reset --hard`).then(({ stdout, stderr }) => {
+      await execAsync(`git fetch origin && git -C ${repoPath} reset --hard origin/${currentBranch}`).then(({ stdout, stderr }) => {
         this.logger.info(`------------------ git -C ${repoPath} reset --hard ------------------`);
         this.logger.error(`stderr: ${stderr}`);
         this.logger.info(`stdout: ${stdout}`);