GIT_ADD_CONFIG - Adicionar Configuração ao Repositório
O que é este Node?
O GIT_ADD_CONFIG é o node responsável por adicionar ou modificar configurações do Git no repositório local. Ele executa o comando git config.
Por que este Node existe?
Repositórios Git podem ter configurações específicas. O GIT_ADD_CONFIG existe para:
- Personalização: Configurar comportamento específico do repositório
- Automação: Definir configs programaticamente
- Integração: Configurar hooks, aliases e ferramentas
- Padronização: Garantir configs consistentes
Como funciona internamente?
Quando o GIT_ADD_CONFIG é executado, o sistema:
- Recebe key e value: Obtém configuração a ser definida
- Substitui variáveis: Aplica variáveis do contexto
- Executa config: Roda
git config [key] "[value]" - Retorna confirmação: Confirma adição da config
Código interno (git.executor.ts:175-181):
private async addConfig(repoPath: string, key: string, value: string, context: ExecutionContext): Promise<any> {
const replacedKey = this.replaceVariables(key, context.variables);
const replacedValue = this.replaceVariables(value, context.variables);
const output = await this.execGit(repoPath, `config ${replacedKey} "${replacedValue}"`, context);
return { output, configAdded: true };
}
Quando você DEVE usar este Node?
Use GIT_ADD_CONFIG quando precisar de configurar repositório:
Casos de uso
- Setup automático: "Configurar hooks em clone novo"
- Padronização: "Definir configs obrigatórias"
- Integração: "Configurar remote URLs dinâmicas"
- Customização: "Ajustar comportamento do Git"
Quando NÃO usar GIT_ADD_CONFIG
- Configuração global: Use GIT_USER_SETUP ou configure manualmente
- Configs sensíveis: Não armazene senhas ou tokens
Parâmetros Detalhados
repositoryPath (string, obrigatório)
O que é: Caminho absoluto para o repositório Git.
Padrão: Nenhum (obrigatório informar)
key (string, obrigatório)
O que é: Chave da configuração Git a ser definida.
Padrão: Nenhum (obrigatório informar)
Exemplos comuns:
- core.autocrlf - Conversão de line endings
- remote.origin.url - URL do repositório remoto
- core.filemode - Permissões de arquivo
- pull.rebase - Comportamento do pull
Flow completo para testar:
{
"name": "Teste Git Add Config - Key",
"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": "Config Key",
"parameters": {
"message": "Digite a chave de config:",
"variable": "config_key"
}
}
},
{
"id": "input_2",
"type": "input",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Config Value",
"parameters": {
"message": "Digite o valor:",
"variable": "config_value"
}
}
},
{
"id": "git_config_1",
"type": "git",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Add Config",
"operation": "addConfig",
"repositoryPath": "/var/www/app",
"key": "{{config_key}}",
"value": "{{config_value}}",
"responseVariable": "config_result"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 900, "y": 100 },
"data": {
"label": "Confirmação",
"parameters": {
"message": "Configuração {{config_key}} definida com sucesso!"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 1100, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "input_1" },
{ "source": "input_1", "target": "input_2" },
{ "source": "input_2", "target": "git_config_1" },
{ "source": "git_config_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Teste: Digite "core.autocrlf" e "input" quando solicitado.
value (string, obrigatório)
O que é: Valor a ser atribuído à configuração.
Padrão: Nenhum (obrigatório informar)
Parâmetros
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| operation | string | Sim | Deve ser "addConfig" |
| repositoryPath | string | Sim | Caminho do repositório local |
| key | string | Sim | Chave da configuração |
| value | string | Sim | Valor da configuração |
| responseVariable | string | Não | Variável para armazenar resultado |
Exemplo 1: Configurar Remote URL
Objetivo: Definir URL do repositório remoto dinamicamente
JSON para Importar
{
"name": "Configurar Remote URL",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "variable_1",
"type": "variable",
"position": { "x": 300, "y": 100 },
"data": {
"label": "Remote URL",
"parameters": {
"variable": "remote_url",
"value": "git@github.com:empresa/projeto.git"
}
}
},
{
"id": "git_config_1",
"type": "git",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Set Remote",
"operation": "addConfig",
"repositoryPath": "/var/www/app",
"key": "remote.origin.url",
"value": "{{remote_url}}",
"responseVariable": "config_result"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Sucesso",
"parameters": {
"message": "Remote URL configurada: {{remote_url}}"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "variable_1" },
{ "source": "variable_1", "target": "git_config_1" },
{ "source": "git_config_1", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Exemplo 2: Setup de Repositório Padrão
Objetivo: Configurar múltiplas configs em repositório novo
JSON para Importar
{
"name": "Setup Padrão de Repositório",
"nodes": [
{
"id": "start_1",
"type": "start",
"position": { "x": 100, "y": 100 },
"data": { "label": "Início" }
},
{
"id": "git_config_1",
"type": "git",
"position": { "x": 300, "y": 50 },
"data": {
"label": "Config AutoCRLF",
"operation": "addConfig",
"repositoryPath": "/var/www/new-project",
"key": "core.autocrlf",
"value": "input",
"responseVariable": "config1"
}
},
{
"id": "git_config_2",
"type": "git",
"position": { "x": 300, "y": 150 },
"data": {
"label": "Config Filemode",
"operation": "addConfig",
"repositoryPath": "/var/www/new-project",
"key": "core.filemode",
"value": "false",
"responseVariable": "config2"
}
},
{
"id": "git_config_3",
"type": "git",
"position": { "x": 500, "y": 100 },
"data": {
"label": "Config Pull Rebase",
"operation": "addConfig",
"repositoryPath": "/var/www/new-project",
"key": "pull.rebase",
"value": "true",
"responseVariable": "config3"
}
},
{
"id": "message_1",
"type": "message",
"position": { "x": 700, "y": 100 },
"data": {
"label": "Sucesso",
"parameters": {
"message": "Repositório configurado com padrões da empresa!"
}
}
},
{
"id": "end_1",
"type": "end",
"position": { "x": 900, "y": 100 },
"data": { "label": "Fim" }
}
],
"edges": [
{ "source": "start_1", "target": "git_config_1" },
{ "source": "start_1", "target": "git_config_2" },
{ "source": "git_config_1", "target": "git_config_3" },
{ "source": "git_config_2", "target": "git_config_3" },
{ "source": "git_config_3", "target": "message_1" },
{ "source": "message_1", "target": "end_1" }
]
}
Resposta do Node
{
"output": "",
"configAdded": true
}
Boas Práticas
✅ SIM: - Use para configs específicas do repositório - Documente configs customizadas - Valide configs após definir - Use em setup automatizado
❌ NÃO: - Não armazene credenciais em config - Não sobrescreva configs críticas sem backup - Não use para configs globais de usuário
Dicas
💡 Dica 1: Use GIT_USER_SETUP para configurar usuário
💡 Dica 2: Configs ficam em .git/config do repositório
💡 Dica 3: Combine múltiplos configs para setup completo
Próximo Node
→ GIT_USER_SETUP - Configurar usuário Git → GIT_CLONE - Clonar repositório antes de configurar