From 08d40dc7864633d50071421ffcc3a1ac323170b6 Mon Sep 17 00:00:00 2001 From: Jacob Maarse Date: Wed, 14 Sep 2022 09:45:27 -0400 Subject: [PATCH 1/2] Worktree reset when head ref is changed --- Makefile | 7 ++++++- actions/sync.go | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2706df1..6ae069f 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,11 @@ BUILD_DIR := $(PWD)/.build SHELL := /bin/bash UNAME := $(shell uname) ARCH := $(shell uname -m) +GOARCH := $(ARCH) + +ifeq ($(findstring x86_64,$(ARCH)),x86_64) + GOARCH := amd64 +endif GO_SOURCES := $(shell find `echo *` -name '*.go') @@ -39,7 +44,7 @@ ifeq ($(OS),darwin) $(BUILD_DIR)/go/bin/go: @echo installing go... @mkdir -p $(BUILD_DIR)/bin - @cd $(BUILD_DIR) && curl -Ls https://golang.org/dl/go$(GOLANG_VERSION).$(OS)-$(ARCH).tar.gz | tar xz + @cd $(BUILD_DIR) && curl -Ls https://golang.org/dl/go$(GOLANG_VERSION).$(OS)-$(GOARCH).tar.gz | tar xz endif $(BUILD_DIR)/bin/golangci-lint: $(BUILD_DIR)/bin/activate diff --git a/actions/sync.go b/actions/sync.go index 6ffad11..b4c742b 100644 --- a/actions/sync.go +++ b/actions/sync.go @@ -160,6 +160,17 @@ func Sync(c *cli.Context) error { if err != nil { return err } + worktree, err := repo.Worktree() + if err != nil { + return err + } + err = worktree.Reset(&git.ResetOptions{ + Commit: newHeadRef.Hash(), + Mode: git.HardReset, + }) + if err != nil { + return err + } } return nil } From 4ab27162a1451546d60e8356277d2269084fc979 Mon Sep 17 00:00:00 2001 From: Jacob Maarse Date: Wed, 14 Sep 2022 09:54:29 -0400 Subject: [PATCH 2/2] Remove makefile change --- Makefile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 6ae069f..2706df1 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,6 @@ BUILD_DIR := $(PWD)/.build SHELL := /bin/bash UNAME := $(shell uname) ARCH := $(shell uname -m) -GOARCH := $(ARCH) - -ifeq ($(findstring x86_64,$(ARCH)),x86_64) - GOARCH := amd64 -endif GO_SOURCES := $(shell find `echo *` -name '*.go') @@ -44,7 +39,7 @@ ifeq ($(OS),darwin) $(BUILD_DIR)/go/bin/go: @echo installing go... @mkdir -p $(BUILD_DIR)/bin - @cd $(BUILD_DIR) && curl -Ls https://golang.org/dl/go$(GOLANG_VERSION).$(OS)-$(GOARCH).tar.gz | tar xz + @cd $(BUILD_DIR) && curl -Ls https://golang.org/dl/go$(GOLANG_VERSION).$(OS)-$(ARCH).tar.gz | tar xz endif $(BUILD_DIR)/bin/golangci-lint: $(BUILD_DIR)/bin/activate