mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
refactor: panic and rename variable plus move an error so it can actually trigger
This commit is contained in:
@@ -13,12 +13,11 @@ import (
|
|||||||
// An example of the author file can be found in the examples folder of the repo
|
// An example of the author file can be found in the examples folder of the repo
|
||||||
func Find_authorfile() string {
|
func Find_authorfile() string {
|
||||||
if os.Getenv("author_file") == "" {
|
if os.Getenv("author_file") == "" {
|
||||||
authors, err := os.UserConfigDir()
|
dirs, err := os.UserConfigDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error getting user config directory")
|
panic(fmt.Sprintf("Error getting user config directory: %v", err))
|
||||||
os.Exit(2)
|
|
||||||
}
|
}
|
||||||
return (authors + "/cocommit/authors.json")
|
return (dirs + "/cocommit/authors.json")
|
||||||
} else {
|
} else {
|
||||||
return os.Getenv("author_file")
|
return os.Getenv("author_file")
|
||||||
}
|
}
|
||||||
@@ -106,6 +105,12 @@ func CreateAuthor(user User) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DeleteOneAuthor(author string) {
|
func DeleteOneAuthor(author string) {
|
||||||
|
// check that users aren't empty
|
||||||
|
if len(Users) < 1 {
|
||||||
|
fmt.Println("No users to remove")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
author_file := Find_authorfile()
|
author_file := Find_authorfile()
|
||||||
|
|
||||||
if _, exists := Users[author]; !exists {
|
if _, exists := Users[author]; !exists {
|
||||||
@@ -121,12 +126,6 @@ func DeleteOneAuthor(author string) {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
// check that users aren't empty
|
|
||||||
if len(Users) < 1 {
|
|
||||||
fmt.Println("No users to remove")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
usr := Users[author]
|
usr := Users[author]
|
||||||
|
|
||||||
// Remove the user from the Author struct (try both short and long name)
|
// Remove the user from the Author struct (try both short and long name)
|
||||||
|
|||||||
Reference in New Issue
Block a user