Skip to content

Commit

Permalink
Merge pull request #7 from gobuffalo/fix-6-missing-event
Browse files Browse the repository at this point in the history
do not remove-and-add file from watcher when event happens
  • Loading branch information
sio4 authored Oct 20, 2022
2 parents a8045be + 74df080 commit 732e6cb
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 44 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v1
- uses: actions/checkout@v3
with:
go-version: 1.17
id: go
- name: Checkout Code
uses: actions/checkout@master
- name: Run GoReleaser
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
uses: goreleaser/goreleaser-action@v1
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: goreleaser/goreleaser-action@v3
with:
version: latest
verison: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_PAT }}
15 changes: 6 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
builds:
-
main: ./main.go
- main: ./main.go
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X "github.com/gobuffalo/refresh.Version={{.Tag}}"
- -s -w -X "github.com/gobuffalo/refresh/cmd.Version={{.Tag}}"
goos:
- darwin
- linux
Expand All @@ -18,8 +17,7 @@ builds:
- 6
- 7
archives:
-
replacements:
- replacements:
'386': i386
darwin: Darwin
linux: Linux
Expand All @@ -36,10 +34,9 @@ changelog:
- '^docs:'
- '^test:'
brews:
-
name: 'refresh'
github:
owner: 'markbates'
- name: 'refresh'
tap:
owner: 'gobuffalo'
name: 'homebrew-tap'
install: |
bin.install "refresh"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ install:
go install -v .

test:
go test -cover -failfast ./...
go test -race -cover -failfast ./...
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package cmd

const Version = "1.4.0"
const Version = "1.13.3"
5 changes: 3 additions & 2 deletions filenotify/poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ func TestPollerEvent(t *testing.T) {
default:
}

if err := ioutil.WriteFile(f.Name(), []byte("hello"), 0644); err != nil {
if err := ioutil.WriteFile(f.Name(), []byte("hello"), 0600); err != nil {
// consider umask
t.Fatal(err)
}
if err := assertEvent(w, fsnotify.Write); err != nil {
t.Fatal(err)
}

if err := os.Chmod(f.Name(), 600); err != nil {
if err := os.Chmod(f.Name(), 0644); err != nil {
t.Fatal(err)
}
if err := assertEvent(w, fsnotify.Chmod); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.16

require (
github.com/fatih/color v1.13.0
github.com/fsnotify/fsnotify v1.5.4
github.com/fsnotify/fsnotify v1.6.0
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.5.0
gopkg.in/yaml.v2 v2.4.0
github.com/spf13/cobra v1.6.0
gopkg.in/yaml.v3 v3.0.1
)
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
Expand All @@ -13,16 +13,16 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI=
github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956 h1:XeJjHH1KiLpKGb6lvMiksZ9l0fVUh+AmGcm0nOMEBOY=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion refresh/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"time"

yaml "gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v3"
)

type Configuration struct {
Expand Down
2 changes: 0 additions & 2 deletions refresh/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func (r *Manager) Start() error {
if event.Op != fsnotify.Chmod {
go r.build(event)
}
w.Remove(event.Name)
w.Add(event.Name)
case <-r.context.Done():
break LoopRebuilder
}
Expand Down
2 changes: 1 addition & 1 deletion refresh/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (w *Watcher) Start() {
err := filepath.Walk(w.AppRoot, func(path string, info os.FileInfo, err error) error {
if info == nil {
w.cancelFunc()
return errors.New("nil directory!")
return errors.New("nil directory")
}
if info.IsDir() {
if strings.HasPrefix(filepath.Base(path), "_") {
Expand Down
3 changes: 0 additions & 3 deletions version.go

This file was deleted.

0 comments on commit 732e6cb

Please sign in to comment.