Skip to content

Commit

Permalink
remove users by email working
Browse files Browse the repository at this point in the history
  • Loading branch information
zeucapua committed Sep 25, 2024
1 parent db866b3 commit 1661bad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/offboard/offboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewConfigCommand() *cobra.Command {
Long: offboardLongDesc,
Args: func(_ *cobra.Command, args []string) error {
if !(len(args) > 0) {
errors.New("you must provide at least one argument: the offboarding user's email/username")
return errors.New("you must provide at least one argument: the offboarding user's email/username")
}

opts.offboardingUsers = args
Expand Down
9 changes: 6 additions & 3 deletions cmd/offboard/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ func generateOwnersFile(path string, offboardingUsers []string) error {
lines := strings.Split(string(owners), "\n")
var newLines []string
for _, line := range lines {
var result string
newLine := line
for _, name := range offboardingUsers {
result, _, _ = strings.Cut(line, "@"+name)
result, _, found := strings.Cut(newLine, "@"+name)
if found {
newLine = result
}
}
newLines = append(newLines, result)
newLines = append(newLines, newLine)
}

output := strings.Join(newLines, "\n")
Expand Down

0 comments on commit 1661bad

Please sign in to comment.