-
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.
docs: Update package and function level documentations
- Loading branch information
Showing
6 changed files
with
52 additions
and
15 deletions.
There are no files selected for viewing
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,36 +1,30 @@ | ||
package author | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
func extractNameAndEmail(line string) []string { | ||
pattern := `(\w[\w\s]+)\s+<([^>]+)>` | ||
re := regexp.MustCompile(pattern) | ||
return re.FindStringSubmatch(line) | ||
} | ||
|
||
// GetSuggestedCoAuthors retrieves a list of suggested co-authors who have made commits in the Git repository. | ||
// | ||
// This function uses the `git log` command to obtain a list of authors who have made commits in the Git repository. | ||
// It executes the command and processes the output to extract author names and email addresses. The resulting | ||
// list represents suggested co-authors for Git commits. | ||
func GetSuggestedCoAuthors() ([]string, error) { | ||
// Use the `git rev-list` command to obtain a list of authors who have made commits in the Git repository. | ||
revlist := "git log --pretty='%an <%ae>' | sort -u" | ||
cmd := exec.Command("bash", "-c", revlist) | ||
output, err := cmd.CombinedOutput() | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
authorString := strings.TrimSpace(string(output)) | ||
|
||
strings.Replace(authorString, `\n`, "\n", -1) | ||
authorString = strings.ReplaceAll(authorString, `\n`, "\n") | ||
|
||
// Parse the output to extract author names and email addresses. | ||
suggestedCoAuthors := strings.Split(authorString, "\n") | ||
|
||
fmt.Println("suggested authors", suggestedCoAuthors) | ||
|
||
return suggestedCoAuthors, nil | ||
} |
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