Skip to content

Commit 867264d

Browse files
authored
chore(librarian): streamline logging (#2644)
- A lot of Info lines were really only relevant when debugging. - The log entry saying that a library would be released was effectively reporting the command-line `-library` option value, instead of the library that would be released. - The warning for commit message lines not being conventional commit headers should only be a warning if we haven't already found a conventional commit heading. These changes make it much easier to see what's going on when running release init.
1 parent 88c4379 commit 867264d

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

internal/gitrepo/conventional_commits.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ func parseSimpleCommit(commitPart commitPart, commit *Commit, libraryID string)
217217
for _, bodyLine := range bodyLines {
218218
header, ok := parseHeader(bodyLine)
219219
if !ok {
220-
slog.Warn("bodyLine is not a header", "bodyLine", bodyLine, "hash", commit.Hash.String())
221220
if len(commits) == 0 {
222221
// This should not happen as we expect a conventional commit message inside a nested commit.
222+
slog.Warn("bodyLine is not a header, not in a commit", "bodyLine", bodyLine, "hash", commit.Hash.String())
223223
continue
224224
}
225225

internal/gitrepo/gitrepo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (r *LocalRepository) IsClean() (bool, error) {
239239
// ChangedFiles returns a list of files that have been modified, added, or deleted
240240
// in the working tree, including both staged and unstaged changes.
241241
func (r *LocalRepository) ChangedFiles() ([]string, error) {
242-
slog.Info("Getting changed files")
242+
slog.Debug("Getting changed files")
243243
worktree, err := r.repo.Worktree()
244244
if err != nil {
245245
return nil, err
@@ -450,7 +450,7 @@ func getHashForPath(commit *object.Commit, path string) (string, error) {
450450

451451
// ChangedFilesInCommit returns the files changed in the given commit.
452452
func (r *LocalRepository) ChangedFilesInCommit(commitHash string) ([]string, error) {
453-
slog.Info("Getting changed files in commit", "hash", commitHash)
453+
slog.Debug("Getting changed files in commit", "hash", commitHash)
454454
commit, err := r.repo.CommitObject(plumbing.NewHash(commitHash))
455455
if err != nil {
456456
return nil, fmt.Errorf("failed to get commit object for hash %s: %w", commitHash, err)

internal/librarian/release_init.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func (r *initRunner) updateLibrary(library *config.LibraryState, commits []*gitr
272272
// Library was inputted for release, but does not contain a releasable unit
273273
return fmt.Errorf("library does not have a releasable unit and will not be released. Use the version flag to force a release for: %s", library.ID)
274274
}
275-
slog.Info("Updating library to the next version", "library", r.library, "currentVersion", library.Version, "nextVersion", nextVersion)
275+
slog.Info("Updating library to the next version", "library", library.ID, "currentVersion", library.Version, "nextVersion", nextVersion)
276276
}
277277

278278
// Update the previous version, we need this value when creating release note.
@@ -292,13 +292,13 @@ func (r *initRunner) determineNextVersion(commits []*gitrepo.ConventionalCommit,
292292
}
293293

294294
if r.librarianConfig == nil {
295-
slog.Info("No librarian config")
295+
slog.Debug("No librarian config")
296296
return nextVersionFromCommits, nil
297297
}
298298

299299
// Look for next_version override from config.yaml
300300
libraryConfig := r.librarianConfig.LibraryConfigFor(libraryID)
301-
slog.Info("Looking up library config", "library", libraryID, slog.Any("config", libraryConfig))
301+
slog.Debug("Looking up library config", "library", libraryID, slog.Any("config", libraryConfig))
302302
if libraryConfig == nil || libraryConfig.NextVersion == "" {
303303
return nextVersionFromCommits, nil
304304
}

0 commit comments

Comments
 (0)