Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
How do I get the git commit description in node?

I need a safe consitent way to get the git description of latest commit in node.js

git commit -m "some message" -m "this is the description"

I am using require('child_process').execSync('git log -1').toString();

which outputs:

commit f8f42hash5556666b3c518e3hash294b62e88888
Author: Developer Name <email@email.com>
Date:   Tue Jun 28 08:10:09 2022 +0200

    some message

    this is the description

And I know that it is possible to add some -format='????' but following this guide; https://devhints.io/git-log-format I can't seem to find a option that gives me the description...

Edit: I see comments about description and message being treated as oine thing, which surprises me, because gitlabs interface can in fact tell the difference, I have also seen them as separetae fields in som GUI git manager (maybe git kraken or a vscode plugin)..

Here's how it looks in gitlab (--skipSmokeTest is the description) enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can get the message like this: git log -1 --format='%b'
It will return:

some message

this is the description

Then you can extract the second line of text using JavaScript.

about 4 years ago · Juan Pablo Isaza Relatório

0

Beware the correct option is --pretty according to the Git log doc !

For me, you should use this, it works for me: git log -1 --pretty="format:%s".

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda