Skip to content

Commit

Permalink
Summary functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
kuritka committed Mar 15, 2021
1 parent baba932 commit 772c4d1
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/inspect.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 ABSA Group Limited
# Copyright 2021 Absa Group Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 ABSA Group Limited
# Copyright 2021 Absa Group Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ create `.licignore`
````
And run **GOLIC**
```shell
go install github.com/AbsaOSS/[email protected]
# GO 1.16
go install github.com/AbsaOSS/[email protected]
golic inject -c="2021 MyCompany ltd."
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/inject.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/runner.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 ABSA Group Limited
# Copyright 2021 Absa Group Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/AbsaOSS/golic

go 1.15
go 1.16

require (
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect
Expand Down
155 changes: 155 additions & 0 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion impl/inject/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
16 changes: 15 additions & 1 deletion impl/inject/inject.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -78,12 +78,16 @@ func read(f string) (s string, err error) {
}

func (i *Inject) traverse() {
skipped := 0
visited := 0
p := func(path string, i gitignore.GitIgnore, o Options, config *Config) (err error) {
if !i.Ignore(path) {
var skip bool
symbol := ""
visited++
if err,skip = inject(path,o, config); skip {
symbol = "-> skip"
skipped++
}
emoji.Printf(" %s %s %s \n",emoji.Minus, aurora.BrightYellow(path), aurora.BrightMagenta(symbol))
}
Expand All @@ -103,6 +107,16 @@ func (i *Inject) traverse() {
if err != nil {
logger.Err(err).Msg("")
}
summary(skipped,visited)
}


func summary(skipped, visited int) {
if skipped == visited {
fmt.Printf("\n %s %v/%v %s\n\n", emoji.Ice, aurora.BrightCyan(visited-skipped), aurora.BrightWhite(visited), aurora.BrightBlue("changed"))
return
}
fmt.Printf("\n %s %v/%v %s\n\n", emoji.Fire, aurora.BrightMagenta(visited-skipped), aurora.BrightWhite(visited), aurora.BrightYellow("changed"))
}

func inject(path string, o Options, config *Config) (err error, skip bool) {
Expand Down
2 changes: 1 addition & 1 deletion impl/inject/opts.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion impl/remove/opts.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion utils/guard/guard.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion utils/log/log.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 ABSA Group Limited
Copyright 2021 Absa Group Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 772c4d1

Please sign in to comment.