question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Format strings instead of values in git.log

See original GitHub issue

git.log has formating strings in result

  ],
  latest: {
    hash: 'd4a703f32ab09f15836d4e2fcde57a5ae3ac7b68',
    date: '%aI',
    message: 'init',
    refs: '%D',
    body: '',
    author_name: 'name',
    author_email: 'name@company'
  },
  total: 1
}

Works find locally (macos) but is incorrect when deployed on an alpine linux instance

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
prevueltacommented, Dec 20, 2020

Awesome - thanks heaps - will try and get an updated image created, but in the meantime thanks for the quick fix!

1reaction
steveukxcommented, Dec 20, 2020

The version of git you are using doesn’t support %D as a token in the format string (it was added in 2.2.3).

If you aren’t able to update your git installation, you can work around this by passing in a format object to the git.log call:

const log = await git.log({
  file: path.join(cwd, 'docs/file.md')
  format: {
    hash: '%H',
    date: '%ai',
    message: '%s',
    refs: '%d',
    body: '%b',
    author_name: '%aN',
    author_email: '%aE',
  }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

pretty-formats Documentation - Git
The format:<format-string> format allows you to specify which information you want to show. It works a little bit like printf format, with the...
Read more >
Git log format string cheatsheet - Devhints
Git log format string cheatsheet. #Log format. Pretty format.
Read more >
Use Git log to format the commit history - Edureka
In this article, we will discuss some advanced options to format and print the commit logs to fetch the information that you need...
Read more >
Format string for consistent separation between entries output ...
From the git log man page: -z. Separate the commits with NULs instead of with ...
Read more >
Advanced Git Log | Atlassian Git Tutorial
The advanced features of git log can be split into two categories: formatting how each commit is displayed, and filtering which commits are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found