forked from ribice/glice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates for
glice audit
to work but w/o tests.
- Loading branch information
Mike Schinkel
committed
Oct 19, 2022
1 parent
f28b4a2
commit 32d5b9e
Showing
24 changed files
with
372 additions
and
237 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,44 @@ | ||
package glice | ||
|
||
import ( | ||
"log" | ||
) | ||
import "sort" | ||
|
||
type Changes struct { | ||
Old []string | ||
New []string | ||
Additions []string | ||
Deletions []string | ||
} | ||
|
||
func NewChanges() *Changes { | ||
return &Changes{ | ||
Old: make([]string, 0), | ||
New: make([]string, 0), | ||
Additions: make([]string, 0), | ||
Deletions: make([]string, 0), | ||
} | ||
} | ||
|
||
// HasChanges returns true if there are either old or new changes | ||
func (c *Changes) HasChanges() bool { | ||
return len(c.Old) > 0 || len(c.New) > 0 | ||
return len(c.Additions) > 0 || len(c.Deletions) > 0 | ||
} | ||
|
||
// Print outputs all changes, old and new | ||
func (c *Changes) Print() { | ||
LogPrintFunc(func() { | ||
showChanges(c.Old, "Old", "These imports were not found in glice.yaml but were found when scanning.") | ||
showChanges(c.New, "New", "These imports were not found when scanning but were found in glice.yaml.") | ||
LogPrintFunc(WarnLevel, func() { | ||
showChanges(c.Additions, "Additions", "These imports were not found in glice.yaml but were found when scanning:") | ||
showChanges(c.Deletions, "Deletions", "These imports were not found when scanning but were found in glice.yaml:") | ||
}) | ||
} | ||
|
||
func showChanges(list []string, _type, descr string) { | ||
log.Printf("\nChanges: %s", _type) | ||
log.Println("------------") | ||
log.Println(descr) | ||
if len(list) == 0 { | ||
goto end | ||
} | ||
sort.Strings(list) | ||
Notef("\n%s", _type) | ||
Notef("\n---------") | ||
Notef("\n%s", descr) | ||
Notef("\n") | ||
for _, imp := range list { | ||
log.Printf(" - %s\n", imp) | ||
Notef("\n - %s", imp) | ||
} | ||
log.Println("") | ||
Notef("\n\n") | ||
end: | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.