Skip to content

Commit

Permalink
Ignore dot files and make command files executable, fixes #1822 (#1861)
Browse files Browse the repository at this point in the history
* Ignore dot files and make command files executable
* Add info about command line endings to docs
  • Loading branch information
rfay committed Nov 2, 2019
1 parent cd302a0 commit 70a8b0d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cmd/ddev/cmd/commands.go
Expand Up @@ -50,13 +50,17 @@ func addCustomCommands(rootCmd *cobra.Command) error {
}

for _, commandName := range commandFiles {
if strings.HasSuffix(commandName, ".example") || strings.HasPrefix(commandName, "README") {
if strings.HasSuffix(commandName, ".example") || strings.HasPrefix(commandName, "README") || strings.HasPrefix(commandName, ".") {
continue
}
// Use path.Join() for the inContainerFullPath because it's about the path in the container, not on the
// host; a Windows path is not useful here.
inContainerFullPath := path.Join("/mnt/ddev_config/commands", service, commandName)
onHostFullPath := filepath.Join(topCommandPath, service, commandName)

// Any command we find will want to be executable on Linux
_ = os.Chmod(onHostFullPath, 0755)

description := findDirectiveInScript(onHostFullPath, "## Description")
if description == "" {
description = commandName
Expand Down
1 change: 1 addition & 0 deletions docs/users/extend/custom-commands.md
Expand Up @@ -88,5 +88,6 @@ Useful variables for container scripts are:

## Known Windows OS issues

* **Line Endings**: If you are editing a custom command which will run in a container, it must have LF line endings (not traditional Windows CRLF line endings). Remember that a custom command in a container is a script that must execute in a Linux environmet.
* If ddev can't find "bash" to execute it, then the commands can't be used. If you are running inside git-bash in most any terminal, this shouldn't be an issue, and ddev should be able to find git-bash if it's in "C:\Program Files\Git\bin" as well. But if neither of those is true, add the directory of bash.exe to your PATH environment variable.
* If you're using Docker Toolbox, the IP address for things like `ddev mysql` is not 127.0.0.1, it's likely 192.168.99.100.
2 changes: 1 addition & 1 deletion pkg/ddevapp/config.go
Expand Up @@ -908,7 +908,7 @@ func PrepDdevDirectory(dir string) error {
}
}

err := CreateGitIgnore(dir, "commands/*/*.example", "commands/*/README.txt", "homeadditions/*.example", "homeadditions/README.txt", "import.yaml", "docker-compose.yaml", "db_snapshots", "sequelpro.spf", "import-db", ".bgsync*", "config.*.y*ml", ".webimageBuild", ".dbimageBuild", ".bgsyncimageBuild", ".sshimageBuild", ".webimageExtra", ".dbimageExtra", "*-build/Dockerfile.example")
err := CreateGitIgnore(dir, "commands/*/*.example", "commands/*/README.txt", "commands/host/launch", "commands/db/mysql", "homeadditions/*.example", "homeadditions/README.txt", ".gitignore", "import.yaml", "docker-compose.yaml", "db_snapshots", "sequelpro.spf", "import-db", ".bgsync*", "config.*.y*ml", ".webimageBuild", ".dbimageBuild", ".bgsyncimageBuild", ".sshimageBuild", ".webimageExtra", ".dbimageExtra", "*-build/Dockerfile.example")
if err != nil {
return fmt.Errorf("failed to create gitignore in %s: %v", dir, err)
}
Expand Down

0 comments on commit 70a8b0d

Please sign in to comment.