GIT_FETCH - Buscar Atualizações do Repositório Remoto
O que é este Node?
O GIT_FETCH é o node responsável por buscar atualizações do repositório remoto sem mesclar com o branch local. Ele executa o comando git fetch.
Por que este Node existe?
Diferente do pull, o fetch apenas baixa as atualizações sem aplicá-las, permitindo revisão antes de mesclar. O GIT_FETCH existe para:
- Verificação Segura: Ver mudanças remotas antes de aplicar
- Sincronização: Atualizar referências remotas
- Análise: Comparar local com remoto antes de merge
- Preparação: Buscar mudanças para processar depois
Como funciona internamente?
Quando o GIT_FETCH é executado, o sistema:
- Valida repositório: Verifica se o path é válido
- Executa fetch: Roda
git fetch - Atualiza referências: Atualiza origin/* refs
- Se erro: Lança exceção
- Se sucesso: Retorna confirmação
Código interno (git.executor.ts:136-139):
private async fetch(repoPath: string, context: ExecutionContext): Promise<any> {
const output = await this.execGit(repoPath, 'fetch', context);
return { output, fetched: true };
}
Quando você DEVE usar este Node?
Use GIT_FETCH quando precisar de buscar mudanças sem aplicar:
Casos de uso
- Verificação prévia: "Verificar se há atualizações remotas"
- Comparação: "Comparar branch local com remota"
- CI/CD: "Buscar atualizações antes de build"
- Monitoramento: "Verificar periodicamente por mudanças"
Quando NÃO usar GIT_FETCH
- Atualização imediata: Use GIT_PULL para buscar e aplicar
- Sem repositório remoto: Impossível buscar
Parâmetros
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| operation | string | Sim | Deve ser "fetch" |
| repositoryPath | string | Sim | Caminho do repositório local |
| responseVariable | string | Não | Variável para armazenar resultado |
Exemplo 1: Fetch e Verificação
Objetivo: Buscar atualizações e verificar se há mudanças
JSON para Importar
{
"name": "Fetch e Verificar",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "git_fetch_1",
"type": "git",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Fetch Updates",
"operation": "fetch",
"repositoryPath": "/var/www/app",
"responseVariable": "fetch_result"
}
},
{
"id": "git_status_1",
"type": "git",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Check Status",
"operation": "status",
"repositoryPath": "/var/www/app",
"responseVariable": "status_result"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Resultado",
"parameters": {
"message": "Fetch realizado!\nStatus: {{status_result.status}}"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "git_fetch_1" },
{ "source": "git_fetch_1", "target": "git_status_1" },
{ "source": "git_status_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Exemplo 2: Fetch com Pull Condicional
Objetivo: Fazer fetch e pull apenas se houver atualizações
JSON para Importar
{
"name": "Fetch e Pull Condicional",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "git_fetch_1",
"type": "git",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Fetch",
"operation": "fetch",
"repositoryPath": "/var/www/app",
"responseVariable": "fetch_result"
}
},
{
"id": "git_status_1",
"type": "git",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Status",
"operation": "status",
"repositoryPath": "/var/www/app",
"responseVariable": "status_result"
}
},
{
"id": "condition_1",
"type": "condition",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Tem Updates?",
"parameters": {
"condition": "{{status_result.status}}.includes('behind')"
}
}
},
{
"id": "git_pull_1",
"type": "git",
"position": { "x": 900, "y": 50 },
"data": {
"label": "Pull",
"operation": "pull",
"repositoryPath": "/var/www/app",
"responseVariable": "pull_result"
}
},
{
"id": "message_updated",
"type": "message",
"position": { "x": 1100, "y": 50 },
"data": {
"label": "Atualizado",
"parameters": {
"message": "Repositório atualizado com sucesso!"
}
}
},
{
"id": "message_current",
"type": "message",
"position": { "x": 900, "y": 150 },
"data": {
"label": "Atual",
"parameters": {
"message": "Repositório já está atualizado"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 1300, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "git_fetch_1" },
{ "source": "git_fetch_1", "target": "git_status_1" },
{ "source": "git_status_1", "target": "condition_1" },
{ "source": "condition_1", "target": "git_pull_1", "label": "true" },
{ "source": "condition_1", "target": "message_current", "label": "false" },
{ "source": "git_pull_1", "target": "message_updated" },
{ "source": "message_updated", "target": "end_1" },
{ "source": "message_current", "target": "end_1" }
]
}
Resposta do Node
{
"output": "remote: Enumerating objects: 5, done.\nremote: Counting objects: 100% (5/5), done.",
"fetched": true
}
Boas Práticas
✅ SIM: - Use fetch antes de pull em ambientes críticos - Verifique status após fetch - Use em monitoramento periódico
❌ NÃO: - Não confunda fetch com pull - Não espere que mudanças sejam aplicadas automaticamente
Dicas
💡 Dica 1: Combine com GIT_STATUS para ver diferenças após fetch
💡 Dica 2: Use SCHEDULE para fetch periódico automático
💡 Dica 3: Fetch não altera arquivos locais, apenas atualiza referências
Próximo Node
→ GIT_PULL - Buscar e aplicar mudanças → GIT_STATUS - Ver status após fetch