From 54285f09b2d843940f9402ea17e2e43b9ad6ecd9 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 28 Nov 2018 02:04:38 +0000 Subject: [PATCH 01/10] Don't override ldflags This re-enables the main.version, main.commit, and main.date variables. --- .goreleaser.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d0b43a3bb9a..85afea23b55 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -7,8 +7,6 @@ builds: - binary: chezmoi env: - CGO_ENABLED=0 - ldflags: - - -s -w goos: - linux - darwin From fd0e0a7e3de5c3fe9ab13c5d5d141a0d936504c4 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 28 Nov 2018 02:09:56 +0000 Subject: [PATCH 02/10] Activate goreleaser's homebrew support --- .goreleaser.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 85afea23b55..1518589c58b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -76,17 +76,17 @@ nfpm: 386: i386 arm: armel -## generate a homebrew formula and push to github.com/twpayne/homebrew-taps -# brew: -# github: -# owner: twpayne -# name: homebrew-taps -# commit_author: -# name: Tom Payne -# email: TODO@TODO.tld -# folder: Formula -# homepage: "https://github.com/twpayne/chezmoi" -# description: "chezmoi is a tool for managing your dotfiles across multiple machines." +# generate a homebrew formula and push to github.com/twpayne/homebrew-taps +brew: + github: + owner: twpayne + name: homebrew-taps + commit_author: + name: Tom Payne + email: twpayne@gmail.com + folder: Formula + homepage: "https://github.com/twpayne/chezmoi" + description: "chezmoi is a tool for managing your dotfiles across multiple machines." ## generate and push docker images: # dockers: From 61cf4fa1f2e83945b442512b3cf178a20cf91a1b Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 28 Nov 2018 02:10:04 +0000 Subject: [PATCH 03/10] Add newline at end of file --- .goreleaser.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 1518589c58b..0b27eb76c19 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -124,4 +124,4 @@ brew: # - "twpayne/chezmoi:{{ .Tag }}-arm" # v1.0.0 # - "twpayne/chezmoi:v{{ .Major }}-arm" # v1 # - "twpayne/chezmoi:v{{ .Major }}.{{ .Minor }}-arm" # v1.0 -# - "twpayne/chezmoi:latest-arm" \ No newline at end of file +# - "twpayne/chezmoi:latest-arm" From bf8b8614f9494504e5f1231b8ae9a2aeea16b49a Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 29 Nov 2018 18:27:23 +0100 Subject: [PATCH 04/10] Download modules before starting parallel build --- .goreleaser.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0b27eb76c19..e65afcacfda 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -3,10 +3,15 @@ # project_name: chezmoi +before: + hooks: + - go mod download + builds: - binary: chezmoi env: - CGO_ENABLED=0 + - GO111MODULE=on goos: - linux - darwin From dde693c5d10b006f3dfd8c107ce175f373d9eef4 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 29 Nov 2018 18:30:52 +0100 Subject: [PATCH 05/10] Populate vendor and maintainer fields for Linux packages --- .goreleaser.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e65afcacfda..a9e188c5c15 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -59,9 +59,9 @@ changelog: ## generate RPM and DEB packages nfpm: - vendor: "TODO" + vendor: "Tom Payne " homepage: "https://github.com/twpayne/chezmoi" - maintainer: Tom Payne + maintainer: Tom Payne description: "chezmoi is a tool for managing your dotfiles across multiple machines." license: MIT formats: From dc5d032075434973fe4e7e21cc1843d3ad811434 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 29 Nov 2018 18:32:24 +0100 Subject: [PATCH 06/10] Move release comment to README.md --- .goreleaser.yaml | 3 --- README.md | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a9e188c5c15..97f41138590 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,6 +1,3 @@ -# run a local "snapshot" build without publishing: -# TRAVIS_BUILD_NUMBER=1 goreleaser --snapshot --rm-dist --debug -# project_name: chezmoi before: diff --git a/README.md b/README.md index e09c99dc196..826593b0ec4 100644 --- a/README.md +++ b/README.md @@ -335,6 +335,10 @@ To create a new release, push a tag, eg: $ git tag -a v0.1.0 -m "First release" $ git push origin v0.1.0 +To run a local "snapshot" build without publishing: + + $ TRAVIS_BUILD_NUMBER=1 goreleaser --snapshot --rm-dist --debug + ## License The MIT License (MIT) From 8db1e4e34419691f1c5b4d0395561d24f57c8a11 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 29 Nov 2018 18:40:51 +0100 Subject: [PATCH 07/10] Use slower but cross-platform test for empty directories --- lib/chezmoi/chezmoi.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/chezmoi/chezmoi.go b/lib/chezmoi/chezmoi.go index 9b00bdacc9b..b97b4b47891 100644 --- a/lib/chezmoi/chezmoi.go +++ b/lib/chezmoi/chezmoi.go @@ -12,7 +12,6 @@ import ( "sort" "strconv" "strings" - "syscall" "text/template" "time" @@ -363,7 +362,11 @@ func (ts *TargetState) Add(fs vfs.FS, target string, info os.FileInfo, addEmpty, // If the directory is empty, add a .keep file so the directory is // managed by git. Chezmoi will ignore the .keep file as it begins with // a dot. - if stat, ok := info.Sys().(*syscall.Stat_t); ok && stat.Nlink == 2 { + infos, err := fs.ReadDir(target) + if err != nil { + return err + } + if len(infos) == 0 { if err := actuator.WriteFile(filepath.Join(ts.SourceDir, sourceName, ".keep"), nil, 0666&^ts.Umask, nil); err != nil { return err } From 23bab7445df58d7b8a3caf14b9f84d643542d6a3 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 29 Nov 2018 18:43:42 +0100 Subject: [PATCH 08/10] Don't attempt to get umask on Windows --- cmd/root.go | 8 -------- cmd/umask.go | 12 ++++++++++++ cmd/umask_windows.go | 5 +++++ 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 cmd/umask.go create mode 100644 cmd/umask_windows.go diff --git a/cmd/root.go b/cmd/root.go index 7ba9801123c..8a5dade946d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -4,7 +4,6 @@ import ( "fmt" "os" "path/filepath" - "syscall" "github.com/mitchellh/go-homedir" "github.com/spf13/cobra" @@ -97,10 +96,3 @@ func (c *Config) persistentPreRunRootE(fs vfs.FS, command *cobra.Command, args [ } return nil } - -func getUmask() int { - // FIXME should we call runtime.LockOSThread or similar? - umask := syscall.Umask(0) - syscall.Umask(umask) - return umask -} diff --git a/cmd/umask.go b/cmd/umask.go new file mode 100644 index 00000000000..ac28aef9507 --- /dev/null +++ b/cmd/umask.go @@ -0,0 +1,12 @@ +//+build !windows + +package cmd + +import "syscall" + +func getUmask() int { + // FIXME should we call runtime.LockOSThread or similar? + umask := syscall.Umask(0) + syscall.Umask(umask) + return umask +} diff --git a/cmd/umask_windows.go b/cmd/umask_windows.go new file mode 100644 index 00000000000..82bdbaf69bb --- /dev/null +++ b/cmd/umask_windows.go @@ -0,0 +1,5 @@ +package cmd + +func getUmask() int { + return 0 +} From 53c9b20abe481c7bd6f66cf520d09390ca259dc8 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 29 Nov 2018 18:48:26 +0100 Subject: [PATCH 09/10] Use more portable method for getting stdin's fd --- cmd/keyring_set.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/keyring_set.go b/cmd/keyring_set.go index 791566d9ad5..14ada47f525 100644 --- a/cmd/keyring_set.go +++ b/cmd/keyring_set.go @@ -2,7 +2,7 @@ package cmd import ( "fmt" - "syscall" + "os" "github.com/spf13/cobra" "github.com/twpayne/go-vfs" @@ -28,7 +28,7 @@ func (c *Config) runKeyringSetCommand(fs vfs.FS, cmd *cobra.Command, args []stri passwordString := c.keyring.password if passwordString == "" { fmt.Print("Password: ") - password, err := terminal.ReadPassword(syscall.Stdin) + password, err := terminal.ReadPassword(int(os.Stdin.Fd())) if err != nil { return err } From 9fdf9d1a3e5e83d88420470cee158a7fa2688cba Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 29 Nov 2018 18:48:36 +0100 Subject: [PATCH 10/10] Enable Windows releases --- .goreleaser.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 97f41138590..6f6c6347688 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -12,8 +12,7 @@ builds: goos: - linux - darwin - # TODO: uncomment when compatible with windows. currently fails on 'undefined: syscall.Stat_t' - # - windows + - windows - freebsd - openbsd # - dragonfly