GIT_LOG - Visualizar Histórico de Commits
O que é este Node?
O GIT_LOG é o node responsável por visualizar o histórico de commits do repositório Git, retornando informações estruturadas sobre cada commit.
Por que este Node existe?
Para auditoria, análise e documentação, precisamos acessar o histórico de commits. O GIT_LOG existe para:
- Auditoria: Rastrear mudanças e autores
- Análise: Entender evolução do projeto
- Documentação: Gerar changelogs automaticamente
- Debugging: Investigar quando mudanças foram introduzidas
Como funciona internamente?
Quando o GIT_LOG é executado, o sistema:
- Define limite: Usa limite especificado ou padrão (10)
- Executa log: Roda
git logcom formato customizado - Parseia output: Converte output em array de objetos
- Retorna estrutura: Fornece lista de commits com detalhes
Código interno (git.executor.ts:146-156):
private async log(repoPath: string, limit: number, context: ExecutionContext): Promise<any> {
const limitNum = limit || 10;
const output = await this.execGit(repoPath, `log -n ${limitNum} --pretty=format:"%H|%an|%ae|%ad|%s"`, context);
const commits = output.split('\n').map(line => {
const [hash, author, email, date, subject] = line.split('|');
return { hash, author, email, date, subject };
});
return { commits, count: commits.length };
}
Quando você DEVE usar este Node?
Use GIT_LOG quando precisar de acessar histórico de commits:
Casos de uso
- Changelog automático: "Gerar changelog com últimos commits"
- Auditoria: "Ver quem fez mudanças em período específico"
- Análise: "Identificar commits relacionados a bug"
- Documentação: "Listar commits de uma release"
Quando NÃO usar GIT_LOG
- Mudanças de arquivos específicos: Use
git log [file]manualmente - Diff completo: Use outro comando Git
Parâmetros Detalhados
repositoryPath (string, obrigatório)
O que é: Caminho absoluto para o repositório Git.
Padrão: Nenhum (obrigatório informar)
limit (number, opcional)
O que é: Número máximo de commits a retornar.
Padrão: 10 (últimos 10 commits)
Flow completo para testar:
{
"name": "Teste Git Log - Limit",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "input_1",
"type": "input",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Quantidade",
"parameters": {
"message": "Quantos commits mostrar?",
"variable": "commit_count"
}
}
},
{
"id": "git_log_1",
"type": "git",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Get Log",
"operation": "log",
"repositoryPath": "/var/www/app",
"limit": "{{commit_count}}",
"responseVariable": "log_result"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Mostrar Log",
"parameters": {
"message": "Últimos {{log_result.count}} commits encontrados"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "input_1" },
{ "source": "input_1", "target": "git_log_1" },
{ "source": "git_log_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Teste: Digite "5" quando solicitado. Sistema retornará últimos 5 commits.
responseVariable (string, opcional)
O que é: Nome da variável onde o log será armazenado.
Padrão: Nenhum (resultado não é armazenado)
Estrutura do retorno:
{
"commits": [
{
"hash": "abc123def456...",
"author": "João Silva",
"email": "joao@example.com",
"date": "Mon Oct 13 10:30:00 2025 -0300",
"subject": "feat: add new feature"
}
],
"count": 1
}
Parâmetros
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| operation | string | Sim | Deve ser "log" |
| repositoryPath | string | Sim | Caminho do repositório local |
| limit | number | Não | Número de commits (padrão: 10) |
| responseVariable | string | Não | Variável para armazenar resultado |
Exemplo 1: Gerar Changelog Automático
Objetivo: Buscar últimos commits e formatar como changelog
JSON para Importar
{
"name": "Changelog Automático",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "git_log_1",
"type": "git",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Get Commits",
"operation": "log",
"repositoryPath": "/var/www/app",
"limit": 20,
"responseVariable": "commits_data"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Changelog Header",
"parameters": {
"message": "CHANGELOG\n=========\n\nÚltimos {{commits_data.count}} commits:\n"
}
}
},
{
"id": "loop_1",
"type": "loop",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Processar Commits",
"parameters": {
"array": "{{commits_data.commits}}",
"itemVariable": "commit"
}
}
},
{
"id": "message_2",
"type": "message",
"position": { "x": 900, "y": 100 },
"data": {
"label": "Commit Line",
"parameters": {
"message": "- {{commit.subject}} ({{commit.author}})"
}
}
},
{
"id": "end_loop",
"type": "end_loop",
"position": { "x": 1100, "y": 100 },
"data": { "label": "Fim Loop" }
},
{
"id": "end_1",
"type": "end",
"position": { "x": 1300, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "git_log_1" },
{ "source": "git_log_1", "target": "message_1" },
{ "source": "message_1", "target": "loop_1" },
{ "source": "loop_1", "target": "message_2" },
{ "source": "message_2", "target": "end_loop" },
{ "source": "end_loop", "target": "end_1" }
]
}
Saída esperada:
Sistema: CHANGELOG
=========
Últimos 20 commits:
Sistema: - feat: add new feature (João Silva)
Sistema: - fix: correct bug in auth (Maria Santos)
Sistema: - docs: update README (Pedro Souza)
...
Exemplo 2: Auditoria de Commits por Autor
Objetivo: Verificar commits de autor específico
JSON para Importar
{
"name": "Auditoria por Autor",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "input_1",
"type": "input",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Nome do Autor",
"parameters": {
"message": "Digite o nome do autor:",
"variable": "author_name"
}
}
},
{
"id": "git_log_1",
"type": "git",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Get All Commits",
"operation": "log",
"repositoryPath": "/var/www/project",
"limit": 50,
"responseVariable": "all_commits"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Resultado",
"parameters": {
"message": "Buscando commits de {{author_name}}...\n\nTotal de commits analisados: {{all_commits.count}}"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "input_1" },
{ "source": "input_1", "target": "git_log_1" },
{ "source": "git_log_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Exemplo 3: Log com Notificação
Objetivo: Enviar últimos commits via notificação
JSON para Importar
{
"name": "Log com Notificação",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "git_log_1",
"type": "git",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Get Recent Commits",
"operation": "log",
"repositoryPath": "/var/www/app",
"limit": 5,
"responseVariable": "recent_commits"
}
},
{
"id": "variable_1",
"type": "variable",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Format Message",
"parameters": {
"variable": "notification_msg",
"value": "Últimos commits:\n\n1. {{recent_commits.commits[0].subject}}\n2. {{recent_commits.commits[1].subject}}\n3. {{recent_commits.commits[2].subject}}"
}
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Enviar Notificação",
"parameters": {
"message": "{{notification_msg}}"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "git_log_1" },
{ "source": "git_log_1", "target": "variable_1" },
{ "source": "variable_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Resposta do Node
{
"commits": [
{
"hash": "abc123def456789...",
"author": "João Silva",
"email": "joao@example.com",
"date": "Mon Oct 13 10:30:00 2025 -0300",
"subject": "feat: add new feature"
},
{
"hash": "def456ghi789012...",
"author": "Maria Santos",
"email": "maria@example.com",
"date": "Sun Oct 12 15:20:00 2025 -0300",
"subject": "fix: correct authentication bug"
}
],
"count": 2
}
Boas Práticas
✅ SIM: - Use limite apropriado para evitar sobrecarga - Combine com LOOP para processar commits - Use para gerar documentação automática - Armazene em variável para processamento posterior
❌ NÃO: - Não busque milhares de commits sem necessidade - Não assuma ordem específica sem verificar - Não confie apenas no subject para análise completa
Dicas
💡 Dica 1: Use LOOP para processar cada commit individualmente
💡 Dica 2: Combine com FORMATTER para criar changelog estruturado
💡 Dica 3: Hash pode ser usado para checkout ou comparação
💡 Dica 4: Use limit adequado: 10-50 para UI, 100+ para análise
💡 Dica 5: Estrutura retornada é array, fácil de iterar
Próximo Node
→ GIT_STATUS - Ver estado atual do repositório → GIT_CREATE_TAG - Criar tag em commit específico