diff --git a/README.md b/README.md index 715cba9..84b8b6e 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,13 @@ git2gpt [flags] /path/to/git/repository ### Ignoring Files -By default, your `.git` directory and your `.gitignore` and `LICENSE` files are ignored. If you want to change this behavior, you should add a `.gptignore` file to your repository. The `.gptignore` file should contain a list of files and directories to ignore, one per line. The `.gptignore` file should be in the same directory as your `.gitignore` file. Please note that this overwrites the default ignore list, so you should include the default ignore list in your `.gptignore` file if you want to keep it. +By default, your `.git` directory and your `.gitignore` files are ignored. Any files in your `.gitignore` are also skipped. If you want to change this behavior, you should add a `.gptignore` file to your repository. The `.gptignore` file should contain a list of files and directories to ignore, one per line. The `.gptignore` file should be in the same directory as your `.gitignore` file. Please note that this overwrites the default ignore list, so you should include the default ignore list in your `.gptignore` file if you want to keep it. ### Flags -* `-p`, `--preamble`: Path to a text file containing a preamble to include at the beginning of the output file. -* `-o`, `--output`: Path to the output file. If not specified, will print to standard output. -* `-e`, `--estimate`: Estimate the tokens of the output file. If not specified, does not estimate. +* `-p`, `--preamble`: Path to a text file containing a preamble to include at the beginning of the output file. +* `-o`, `--output`: Path to the output file. If not specified, will print to standard output. +* `-e`, `--estimate`: Estimate the tokens of the output file. If not specified, does not estimate. ## Contributing diff --git a/lib/lib.go b/lib/lib.go index ccf889d..20e0dab 100644 --- a/lib/lib.go +++ b/lib/lib.go @@ -38,13 +38,21 @@ func shouldIgnore(filePath string, ignoreList []string) bool { func ProcessGitRepo(repoPath, preambleFile string) (string, error) { ignoreFilePath := filepath.Join(repoPath, ".gptignore") + gitignoreFilePath := filepath.Join(repoPath, ".gitignore") var ignoreList []string - ignoreList = append(ignoreList, ".git/*", ".gitignore", "LICENSE") if _, err := os.Stat(ignoreFilePath); err == nil { // .gptignore file exists ignoreList, _ = getIgnoreList(ignoreFilePath) } + ignoreList = append(ignoreList, ".git/*", ".gitignore") + + if _, err := os.Stat(gitignoreFilePath); err == nil { + // .gitignore file exists + // append .gitignore to ignoreList + gitignoreList, _ := getIgnoreList(gitignoreFilePath) + ignoreList = append(ignoreList, gitignoreList...) + } var repoBuilder strings.Builder