Skip to content

Commit 98fd7d2

Browse files
authored
Fix docs and comments (#51)
- Typo fixes - Formatting fixes - Various small inaccuracies - Code comments fixes
1 parent 19e1e86 commit 98fd7d2

23 files changed

+120
-118
lines changed

README.md

Lines changed: 35 additions & 32 deletions
Large diffs are not rendered by default.

auth/auth.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ type githubRepositoriesService interface {
2525

2626
// GithubClient is the data structure that is common between production code and test code. In production code,
2727
// go-github satisfies the PullRequests and Repositories service interfaces, whereas in test the concrete
28-
// implementations for these same services are mocks that return a static slice of pointers to github repositories,
29-
// or a single pointer to a github repository, as appropriate. This allows us to test the workflow of git-xargs
30-
// without actually making API calls to Github when running tests
28+
// implementations for these same services are mocks that return a static slice of pointers to GitHub repositories,
29+
// or a single pointer to a GitHub repository, as appropriate. This allows us to test the workflow of git-xargs
30+
// without actually making API calls to GitHub when running tests
3131
type GithubClient struct {
3232
PullRequests githubPullRequestService
3333
Repositories githubRepositoriesService
@@ -40,7 +40,7 @@ func NewClient(client *github.Client) GithubClient {
4040
}
4141
}
4242

43-
// configureGithubClient creates a Github API client using the user-supplied GITHUB_OAUTH_TOKEN and return the configured Github client
43+
// ConfigureGithubClient creates a GitHub API client using the user-supplied GITHUB_OAUTH_TOKEN and returns the configured GitHub client
4444
func ConfigureGithubClient() GithubClient {
4545
// Ensure user provided a GITHUB_OAUTH_TOKEN
4646
GithubOauthToken := os.Getenv("GITHUB_OAUTH_TOKEN")
@@ -57,7 +57,7 @@ func ConfigureGithubClient() GithubClient {
5757
return client
5858
}
5959

60-
// ensureGithubOauthTokenSet is a sanity check that a value is exported for GITHUB_OAUTH_TOKEN
60+
// EnsureGithubOauthTokenSet is a sanity check that a value is exported for GITHUB_OAUTH_TOKEN
6161
func EnsureGithubOauthTokenSet() error {
6262
if os.Getenv("GITHUB_OAUTH_TOKEN") == "" {
6363
return errors.WithStackTrace(types.NoGithubOauthTokenProvidedErr{})

auth/auth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/stretchr/testify/assert"
88
)
99

10-
// TestConfigureGithubClient performs a sanity check that you can configure a production Github API client
10+
// TestConfigureGithubClient performs a sanity check that you can configure a production GitHub API client
1111
func TestConfigureGithubClient(t *testing.T) {
1212
t.Parallel()
1313

@@ -16,7 +16,7 @@ func TestConfigureGithubClient(t *testing.T) {
1616
}
1717

1818
// TestNoGithubOauthTokenPassed temporarily drops the existing GITHUB_OAUTH_TOKEN env var to ensure that the validation
19-
// code throws an error when it is mising. It then replaces it. This is therefore the one test that cannot be run in
19+
// code throws an error when it is missing. It then replaces it. This is therefore the one test that cannot be run in
2020
// parallel.
2121
func TestNoGithubOAuthTokenPassed(t *testing.T) {
2222
token := os.Getenv("GITHUB_OAUTH_TOKEN")

cmd/git-xargs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func parseSliceFromReader(reader io.Reader) ([]string, error) {
8888
// handleRepoProcessing encapsulates the main processing logic for the supplied repos and printing the run report that
8989
// is built up throughout the processing
9090
func handleRepoProcessing(config *config.GitXargsConfig) error {
91-
// Track whether or not pull requests were skipped
91+
// Track whether pull requests were skipped
9292
config.Stats.SetSkipPullRequests(config.SkipPullRequests)
9393

9494
// Update raw command supplied
@@ -124,7 +124,7 @@ func sanityCheckInputs(config *config.GitXargsConfig) error {
124124
return nil
125125
}
126126

127-
// runGitXargs is the urfave cli app's Action that is called when the user executes the binary
127+
// RunGitXargs is the urfave cli app's Action that is called when the user executes the binary
128128
func RunGitXargs(c *cli.Context) error {
129129
// If someone calls us with no args at all, show the help text and exit
130130
if !c.Args().Present() {

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type GitXargsConfig struct {
3030
Stats *stats.RunStats
3131
}
3232

33-
// NewGitXargsConfig sets reasonable defaults for a GitXargsConfig and returns a pointer to a the config
33+
// NewGitXargsConfig sets reasonable defaults for a GitXargsConfig and returns a pointer to the config
3434
func NewGitXargsConfig() *GitXargsConfig {
3535
return &GitXargsConfig{
3636
DryRun: false,

io/io.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"github.com/sirupsen/logrus"
1212
)
1313

14-
// This utility function accepts a path to the flatfile in which the user has defined their explicitly allowed repos
15-
// It expects repos to be defined one per line in the following format: `gruntwork-io/cloud-nuke` with optional commas
16-
// Stray single and double quotes are also handled and stripped out if they are encountered, and spacing is irrelevant
14+
// ProcessAllowedRepos accepts a path to the flat file in which the user has defined their explicitly allowed repos.
15+
// It expects repos to be defined one per line in the following format: `gruntwork-io/cloud-nuke` with optional commas.
16+
// Stray single and double quotes are also handled and stripped out if they are encountered, and spacing is irrelevant.
1717
func ProcessAllowedRepos(filepath string) ([]*types.AllowedRepo, error) {
1818
logger := logging.GetLogger("git-xargs")
1919

io/io_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestProcessAllowedReposCorrectlyParsesValidReposFile(t *testing.T) {
2525
assert.NoError(t, err)
2626
assert.Equal(t, len(allowedRepos), 3)
2727

28-
// Test that repo names are correctly parsed from the flat file by initiallly setting a map of each repo name
28+
// Test that repo names are correctly parsed from the flat file by initially setting a map of each repo name
2929
// to false, and then updating each entry to true as we find them in the flat file. At the end, all map entries should be true / seen
3030
mapOfExpectedRepoNames := make(map[string]bool)
3131
mapOfExpectedRepoNames["fetch"] = false
@@ -56,7 +56,7 @@ func TestProcessAllowedReposCorrectlyFiltersMalformedInput(t *testing.T) {
5656
// be returned by the function as valid repos to operate on
5757
assert.Equal(t, len(allowedRepos), 3)
5858

59-
// Test that repo names are correctly parsed from the flat file by initiallly setting a map of each repo name
59+
// Test that repo names are correctly parsed from the flat file by initially setting a map of each repo name
6060
// to false, and then updating each entry to true as we find them in the flat file. At the end, all map entries should be true / seen
6161
mapOfExpectedRepoNames := make(map[string]bool)
6262
mapOfExpectedRepoNames["fetch"] = false

io/validate-input.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/gruntwork-io/go-commons/errors"
77
)
88

9-
// Sanity check that user has provided one valid method for selecting repos to operate on
9+
// EnsureValidOptionsPassed checks that user has provided one valid method for selecting repos to operate on
1010
func EnsureValidOptionsPassed(config *config.GitXargsConfig) error {
1111
if len(config.RepoSlice) < 1 && config.ReposFile == "" && config.GithubOrg == "" && len(config.RepoFromStdIn) == 0 {
1212
return errors.WithStackTrace(types.NoRepoSelectionsMadeErr{})

local/local_test.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/urfave/cli"
1111
)
1212

13-
// This variable is set at build time using -ldflags parameters. For example, we typically set this flag in circle.yml
13+
// VERSION is set at build time using -ldflags parameters. For example, we typically set this flag in circle.yml
1414
// to the latest Git tag when building our Go apps:
1515
//
1616
// build-go-binaries --app-name my-app --dest-path bin --ld-flags "-X main.VERSION=$CIRCLE_TAG"
@@ -42,7 +42,7 @@ func setupApp() *cli.App {
4242
app := entrypoint.NewApp()
4343
entrypoint.HelpTextLineWidth = 120
4444

45-
// Override the CLI FlagEnvHinter so it only returns the Usage text of the Flag and doesn't apend the envVar text. Original func https://github.com/urfave/cli/blob/master/flag.go#L652
45+
// Override the CLI FlagEnvHinter, so it only returns the Usage text of the Flag and doesn't append the envVar text. Original func https://github.com/urfave/cli/blob/master/flag.go#L652
4646
cli.FlagEnvHinter = func(envVar, str string) string {
4747
return str
4848
}

0 commit comments

Comments
 (0)