Skip to content

Commit

Permalink
commands,config,t: use single quotes in messages
Browse files Browse the repository at this point in the history
A number of message strings contain embedded filenames, and while
in many cases these are already delimited with single quotes, in
other cases they are not.

We therefore rework the formatting of these messages to accord
with the general practice of using single quotes to delimit
specific filenames.

Note that some of these messages are not yet passed as translation
strings, but we will address that issue in a subsequent commit.
  • Loading branch information
chrisd8088 committed Jan 30, 2022
1 parent ed3decf commit 4d561b8
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions commands/command_migrate_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ func migrateImportCommand(cmd *cobra.Command, args []string) {

filter := git.GetAttributeFilter(cfg.LocalWorkingDir(), cfg.LocalGitDir())
if len(filter.Include()) == 0 {
ExitWithError(errors.Errorf(tr.Tr.Get("No Git LFS filters found in .gitattributes")))
ExitWithError(errors.Errorf(tr.Tr.Get("No Git LFS filters found in '.gitattributes'")))
}

gf := lfs.NewGitFilter(cfg)

for _, file := range args {
if !filter.Allows(file) {
ExitWithError(errors.Errorf(tr.Tr.Get("File %s did not match any Git LFS filters in .gitattributes", file)))
ExitWithError(errors.Errorf(tr.Tr.Get("File %s did not match any Git LFS filters in '.gitattributes'", file)))
}
}

Expand Down
6 changes: 3 additions & 3 deletions commands/command_track.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ ArgsLoop:
attribContents, err = ioutil.ReadFile(".gitattributes")
// it's fine for file to not exist
if err != nil && !os.IsNotExist(err) {
Print("Error reading .gitattributes file")
Print("Error reading '.gitattributes' file")
return
}
// Re-generate the file with merge of old contents and new (to deal with changes)
attributesFile, err = os.OpenFile(".gitattributes", os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0660)
if err != nil {
Print("Error opening .gitattributes file")
Print("Error opening '.gitattributes' file")
return
}
defer attributesFile.Close()
Expand Down Expand Up @@ -189,7 +189,7 @@ ArgsLoop:
var matchedBlocklist bool
for _, f := range gittracked {
if forbidden := blocklistItem(f); forbidden != "" {
Print(tr.Tr.Get("Pattern %s matches forbidden file %s. If you would like to track %s, modify .gitattributes manually.", pattern, f, f))
Print(tr.Tr.Get("Pattern '%s' matches forbidden file '%s'. If you would like to track %s, modify '.gitattributes' manually.", pattern, f, f))
matchedBlocklist = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion commands/command_untrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func untrackCommand(cmd *cobra.Command, args []string) {

attributesFile, err := os.Create(".gitattributes")
if err != nil {
Print(tr.Tr.Get("Error opening .gitattributes for writing"))
Print(tr.Tr.Get("Error opening '.gitattributes' for writing"))
return
}
defer attributesFile.Close()
Expand Down
8 changes: 4 additions & 4 deletions commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func getHookInstallSteps() string {
steps := make([]string, 0, len(hooks))
for _, h := range hooks {
steps = append(steps, fmt.Sprintf(
"Add the following to .git/hooks/%s:\n\n%s",
"Add the following to '.git/hooks/%s':\n\n%s",
h.Type, tools.Indent(h.Contents)))
}

Expand Down Expand Up @@ -263,7 +263,7 @@ func LoggedError(err error, format string, args ...interface{}) {
file := handlePanic(err)

if len(file) > 0 {
fmt.Fprintf(os.Stderr, "\nErrors logged to %s.\nUse `git lfs logs last` to view the log.\n", file)
fmt.Fprintf(os.Stderr, "\nErrors logged to '%s'.\nUse `git lfs logs last` to view the log.\n", file)
}
}

Expand Down Expand Up @@ -416,12 +416,12 @@ func logPanic(loggedError error) string {

if err := tools.MkdirAll(cfg.LocalLogDir(), cfg); err != nil {
full = ""
fmt.Fprintf(fmtWriter, "Unable to log panic to %s: %s\n\n", cfg.LocalLogDir(), err.Error())
fmt.Fprintf(fmtWriter, "Unable to log panic to '%s': %s\n\n", cfg.LocalLogDir(), err.Error())
} else if file, err := os.Create(full); err != nil {
filename := full
full = ""
defer func() {
fmt.Fprintf(fmtWriter, "Unable to log panic to %s\n\n", filename)
fmt.Fprintf(fmtWriter, "Unable to log panic to '%s'\n\n", filename)
logPanicToWriter(fmtWriter, err, lineEnding)
}()
} else {
Expand Down
2 changes: 1 addition & 1 deletion config/git_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func readGitConfig(configs ...*git.ConfigurationSource) (gf *GitFetcher, extensi
}

if len(ignored) > 0 {
fmt.Fprint(os.Stderr, tr.Tr.Get("warning: These unsafe lfsconfig keys were ignored:"), "\n\n")
fmt.Fprint(os.Stderr, tr.Tr.Get("warning: These unsafe '.lfsconfig' keys were ignored:"), "\n\n")
for _, key := range ignored {
fmt.Fprintf(os.Stderr, " %s\n", key)
}
Expand Down
2 changes: 1 addition & 1 deletion t/t-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ begin_test "config: ignoring unsafe lfsconfig keys"

git lfs env 2>&1 | tee status.log

grep "warning: These unsafe lfsconfig keys were ignored:" status.log
grep "warning: These unsafe '.lfsconfig' keys were ignored:" status.log
grep " core.askpass" status.log
)
end_test
Expand Down
4 changes: 2 additions & 2 deletions t/t-migrate-import-no-rewrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ begin_test "migrate import --no-rewrite (no .gitattributes)"
exit 1
fi

grep "No Git LFS filters found in .gitattributes" migrate.log
grep "No Git LFS filters found in '.gitattributes'" migrate.log
)
end_test

Expand Down Expand Up @@ -161,7 +161,7 @@ begin_test "migrate import --no-rewrite (nested .gitattributes)"
exit 1
fi

grep "a.md did not match any Git LFS filters in .gitattributes" migrate.log
grep "a.md did not match any Git LFS filters in '.gitattributes'" migrate.log
)
end_test

Expand Down
4 changes: 2 additions & 2 deletions t/t-track.sh
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ begin_test "track blocklisted files by name"
git add .gitattributes

git lfs track .gitattributes 2>&1 > track.log
grep "Pattern .gitattributes matches forbidden file .gitattributes" track.log
grep "Pattern '.gitattributes' matches forbidden file '.gitattributes'" track.log
)
end_test

Expand All @@ -388,7 +388,7 @@ begin_test "track blocklisted files with glob"
git add .gitattributes

git lfs track ".git*" 2>&1 > track.log
grep "Pattern .git\* matches forbidden file" track.log
grep "Pattern '.git\*' matches forbidden file" track.log
)
end_test

Expand Down

0 comments on commit 4d561b8

Please sign in to comment.