Skip to content

Commit

Permalink
Merge pull request twpayne#878 from twpayne/no-codespaces-workarounds
Browse files Browse the repository at this point in the history
Revert "Add work-around for GitHub Codespaces permission mangling"
  • Loading branch information
twpayne committed Sep 2, 2020
2 parents 1f48816 + d372437 commit 26039ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 34 deletions.
8 changes: 4 additions & 4 deletions cmd/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ func TestAddCommand(t *testing.T) {
),
vfst.TestPath("/home/user/.local/share/chezmoi/dot_config",
vfst.TestIsDir,
vfst.TestModePerm(codespacesDirPerm(0o755)),
vfst.TestModePerm(0o755),
),
vfst.TestPath("/home/user/.local/share/chezmoi/dot_config/htop",
vfst.TestIsDir,
vfst.TestModePerm(codespacesDirPerm(0o755)),
vfst.TestModePerm(0o755),
),
vfst.TestPath("/home/user/.local/share/chezmoi/dot_config/htop/.keep",
vfst.TestModeIsRegular,
Expand All @@ -89,11 +89,11 @@ func TestAddCommand(t *testing.T) {
),
vfst.TestPath("/home/user/.local/share/chezmoi/dot_config",
vfst.TestIsDir,
vfst.TestModePerm(codespacesDirPerm(0o755)),
vfst.TestModePerm(0o755),
),
vfst.TestPath("/home/user/.local/share/chezmoi/dot_config/htop",
vfst.TestIsDir,
vfst.TestModePerm(codespacesDirPerm(0o755)),
vfst.TestModePerm(0o755),
),
vfst.TestPath("/home/user/.local/share/chezmoi/dot_config/htop/.keep",
vfst.TestModeIsRegular,
Expand Down
15 changes: 3 additions & 12 deletions cmd/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ type scriptTestCase struct {

func TestApplyCommand(t *testing.T) {
for _, tc := range []struct {
name string
root map[string]interface{}
noCodespacesDirPermBug bool
name string
root map[string]interface{}
}{
{
name: "create",
Expand All @@ -34,7 +33,6 @@ func TestApplyCommand(t *testing.T) {
root: map[string]interface{}{
"/home/user/dir": &vfst.Dir{Perm: 0o700},
},
noCodespacesDirPermBug: true,
},
{
name: "replace_file_with_dir",
Expand All @@ -56,21 +54,18 @@ func TestApplyCommand(t *testing.T) {
Contents: []byte("contents"),
},
},
noCodespacesDirPermBug: true,
},
{
name: "replace_dir_with_file",
root: map[string]interface{}{
"/home/user/dir/file": &vfst.Dir{Perm: 0o755},
},
noCodespacesDirPermBug: true,
},
{
name: "replace_symlink_with_file",
root: map[string]interface{}{
"/home/user/dir/file": &vfst.Symlink{Target: "target"},
},
noCodespacesDirPermBug: true,
},
{
name: "replace_dir_with_symlink",
Expand Down Expand Up @@ -164,14 +159,10 @@ func TestApplyCommand(t *testing.T) {
defer cleanup()
c := newTestConfig(fs)
assert.NoError(t, c.runApplyCmd(nil, nil))
expectedDirPerm := os.FileMode(0o755)
if !tc.noCodespacesDirPermBug {
expectedDirPerm = codespacesDirPerm(expectedDirPerm)
}
vfst.RunTests(t, fs, "",
vfst.TestPath("/home/user/dir",
vfst.TestIsDir,
vfst.TestModePerm(expectedDirPerm),
vfst.TestModePerm(0o755),
),
vfst.TestPath("/home/user/dir/file",
vfst.TestModeIsRegular,
Expand Down
18 changes: 0 additions & 18 deletions cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"os"
"runtime"
"strconv"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -111,20 +110,3 @@ func TestExercise(t *testing.T) {
)
})
}

var codespaces = false

func init() {
codespaces, _ = strconv.ParseBool(os.Getenv("CODESPACES"))
}

// codespacesDirPerm returns the expected directory permissions to work around a
// bug in GitHub Codespaces, which clears the world-executable bit when creating
// some directories.
//nolint:unparam
func codespacesDirPerm(expectedPerm os.FileMode) os.FileMode {
if codespaces {
return expectedPerm &^ 0o001
}
return expectedPerm
}

0 comments on commit 26039ee

Please sign in to comment.