Compare commits

...

6 Commits

Author SHA1 Message Date
eaf091dc1a upd links
Some checks are pending
CI / Lint (push) Waiting to run
2025-03-12 15:48:43 +00:00
99871a9040 fix links in special thanks 2025-03-12 15:46:56 +00:00
1ca4304806 add Install with Go tools
remove release task from Taskfile
2025-03-12 15:15:42 +00:00
59521e1cd0 rename gen.go to main.go
no changes to file contents
2025-03-12 15:15:08 +00:00
fcb23a3c01 create templates concurrently 2025-03-12 13:30:17 +00:00
c2b7dfcb18 rename registry functions 2025-03-12 12:54:13 +00:00
5 changed files with 37 additions and 22 deletions

View File

@ -7,6 +7,13 @@
## Install
With Go tools:
```bash
go generate ./...
go install ./cmd/gignore
```
With [Task][task]:
```bash
@ -37,7 +44,7 @@ Example:
## Custom Templates
It's possible to add your own custom templates, simply create a directory in `internal/registry/templates`. You'll need to rebuild the project before you can load the new templates.
It's possible to add your own custom templates, simply create a directory in `internal/registry/templates`. You'll need to [reinstall](https://github.com/onyx-and-iris/gignore?tab=readme-ov-file#install) the project before you can load the new templates.
Then pass the dir name as a flag, for example:
@ -53,11 +60,11 @@ If a template is requested but not found in the custom directory then the gitign
[gitignore.io][gitignoreio] For providing such a useful .gitignore service
[mh-cbon][mh-cbon] For writing the [gigo][gigo] client library for gitignore.io
[cuonglm][cuonglm] For writing the [gogi][gogi] client library for gitignore.io
[task]: https://taskfile.dev/
[gitignoreio]: https://www.toptal.com/developers/gitignore
[mh-cbon]: https://github.com/mh-cbon
[gigo]: https://github.com/mh-cbon/gigo
[cuonglm]: https://github.com/cuonglm
[gogi]: https://github.com/cuonglm/gogi
[ignore]: https://github.com/neptship/ignore

View File

@ -23,13 +23,6 @@ tasks:
- task: build-windows
- task: build-linux
release:
desc: Generate the gitignore.io templates and then build the gignore project for Windows and Linux
deps: [generate]
cmds:
- task: build-windows
- task: build-linux
vet:
desc: Vet the code
deps: [fmt]
@ -44,7 +37,7 @@ tasks:
generate:
desc: Generate the gitignore.io templates
cmds:
- go generate .
- go generate ./...
build-windows:
desc: Build the gignore project for Windows

View File

@ -20,10 +20,25 @@ func main() {
log.Fatal(err)
}
errChan := make(chan error)
doneChan := make(chan struct{})
for _, template := range templates {
err := createTemplate(template)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to create template %s: %v\n", template.Name, err)
go func() {
err := createTemplate(template)
if err != nil {
errChan <- fmt.Errorf("Failed to create template %s: %v", template.Name, err)
return
}
doneChan <- struct{}{}
}()
}
for range templates {
select {
case err := <-errChan:
log.Error(err)
case <-doneChan:
}
}
}

View File

@ -8,7 +8,7 @@ import (
log "github.com/sirupsen/logrus"
)
//go:generate go run cmd/gen/gen.go
//go:generate go run cmd/gen/main.go
// Client is a client for managing .gitignore templates.
type Client struct {
@ -32,7 +32,7 @@ func New(options ...Option) *Client {
// List returns a list of available .gitignore templates.
func (c *Client) List() ([]string, error) {
return c.registry.ListTemplates()
return c.registry.List()
}
// Create generates a .gitignore file from the specified template.
@ -60,7 +60,7 @@ func (c *Client) Create(template string) error {
log.Infof("template '%s' found in default gitignoreio registry", template)
}
content, err := c.registry.GetTemplate(template)
content, err := c.registry.Get(template)
if err != nil {
return err
}

View File

@ -41,8 +41,8 @@ func (t *TemplateRegistry) Contains(name string) (bool, error) {
return true, nil
}
// GetTemplate retrieves the content of the gitignore template with the given name.
func (t *TemplateRegistry) GetTemplate(name string) ([]byte, error) {
// Get retrieves the content of the gitignore template with the given name.
func (t *TemplateRegistry) Get(name string) ([]byte, error) {
data, err := fs.ReadFile(t.templates, t.filePath(name))
if err != nil {
return nil, err
@ -50,8 +50,8 @@ func (t *TemplateRegistry) GetTemplate(name string) ([]byte, error) {
return data, nil
}
// ListTemplates lists all the gitignore templates in the registry.
func (t *TemplateRegistry) ListTemplates() ([]string, error) {
// List lists all the gitignore templates in the registry.
func (t *TemplateRegistry) List() ([]string, error) {
var paths []string
err := fs.WalkDir(