Skip to content

Commit

Permalink
Update README and behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
chand1012 committed Mar 17, 2023
1 parent faf9bd3 commit d5ffb58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion lib/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d5ffb58

Please sign in to comment.