Add upstream tracking tools + check-update workflow
This commit is contained in:
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# Mundo Telecom - Verificar atualizações upstream
|
||||
#
|
||||
# Uso: ./check-upstream.sh [repo-dir]
|
||||
# Verifica se há commits novos no GitHub e reporta o que mudou.
|
||||
#
|
||||
# Exemplo:
|
||||
# ./check-upstream.sh /usr/src/fusionpbx
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_DIR="${1:-.}"
|
||||
cd "$REPO_DIR"
|
||||
|
||||
echo "============================================"
|
||||
echo " 📡 Verificando atualizações..."
|
||||
echo " Repositório: $(basename $(git rev-parse --show-toplevel))"
|
||||
echo "============================================"
|
||||
|
||||
# Buscar mudanças do upstream
|
||||
git fetch upstream 2>&1
|
||||
|
||||
# Verificar se está atrás
|
||||
BEHIND=$(git rev-list --count HEAD..upstream/master 2>/dev/null || echo 0)
|
||||
AHEAD=$(git rev-list --count upstream/master..HEAD 2>/dev/null || echo 0)
|
||||
|
||||
echo ""
|
||||
echo " 📊 Status:"
|
||||
echo " Atrás do upstream: $BEHIND commits"
|
||||
echo " À frente do upstream: $AHEAD commits (nossas alterações)"
|
||||
echo ""
|
||||
|
||||
if [ "$BEHIND" -gt 0 ]; then
|
||||
echo " 📋 Últimos commits do upstream:"
|
||||
git log HEAD..upstream/master --oneline --no-decorate -10 2>/dev/null || true
|
||||
echo ""
|
||||
echo " ⚠️ Há $BEHIND novos commits para revisar!"
|
||||
echo " Para atualizar:"
|
||||
echo " git checkout -b update-$(date +%Y%m%d)"
|
||||
echo " git merge upstream/master"
|
||||
echo " # Testar e depois fazer merge na master"
|
||||
echo ""
|
||||
echo " Para ver o diff completo:"
|
||||
echo " git diff HEAD..upstream/master --stat"
|
||||
else
|
||||
echo " ✅ Repositório atualizado com o upstream!"
|
||||
fi
|
||||
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
# Mundo Telecom - Atualizar repositório a partir do upstream
|
||||
#
|
||||
# Uso: ./update-from-upstream.sh [repo-dir]
|
||||
#
|
||||
# Processo:
|
||||
# 1. Busca mudanças do GitHub (upstream)
|
||||
# 2. Cria branch de revisão
|
||||
# 3. Aplica as mudanças
|
||||
# 4. Gera relatório do que mudou
|
||||
# 5. (opcional) Faz merge na master
|
||||
|
||||
REPO_DIR="${1:-.}"
|
||||
cd "$REPO_DIR"
|
||||
|
||||
REPO_NAME=$(basename $(git rev-parse --show-toplevel))
|
||||
BRANCH="update-$(date +%Y%m%d)"
|
||||
|
||||
echo "============================================"
|
||||
echo " 🔄 Atualizando $REPO_NAME"
|
||||
echo "============================================"
|
||||
|
||||
# Buscar upstream
|
||||
echo ""
|
||||
echo "📡 Buscando atualizações do GitHub..."
|
||||
git fetch upstream
|
||||
|
||||
# Verificar se há mudanças
|
||||
BEHIND=$(git rev-list --count HEAD..upstream/master 2>/dev/null || echo 0)
|
||||
|
||||
if [ "$BEHIND" -eq 0 ]; then
|
||||
echo "✅ Já está atualizado!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Criar branch de revisão
|
||||
echo ""
|
||||
echo "🌿 Criando branch de revisão: $BRANCH"
|
||||
git checkout -b "$BRANCH" origin/master 2>/dev/null || git checkout "$BRANCH" 2>/dev/null || git checkout -b "$BRANCH"
|
||||
|
||||
# Merge do upstream
|
||||
echo ""
|
||||
echo "🔀 Aplicando mudanças do upstream..."
|
||||
if git merge upstream/master --no-edit 2>&1; then
|
||||
echo "✅ Merge realizado sem conflitos!"
|
||||
else
|
||||
echo "⚠️ HOUVE CONFLITOS! Resolva manualmente:"
|
||||
echo " 1. git status (ver arquivos conflitantes)"
|
||||
echo " 2. Resolver os conflitos"
|
||||
echo " 3. git add . && git commit"
|
||||
echo " 4. git push origin $BRANCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Relatório de mudanças
|
||||
echo ""
|
||||
echo "📋 Resumo das mudanças:"
|
||||
git diff origin/master..$BRANCH --stat
|
||||
echo ""
|
||||
echo "📋 Commits aplicados:"
|
||||
git log origin/master..$BRANCH --oneline --no-decorate
|
||||
|
||||
# Push
|
||||
echo ""
|
||||
echo "⬆️ Enviando para o Gitea..."
|
||||
git push origin "$BRANCH"
|
||||
|
||||
# Voltar pra master
|
||||
git checkout master
|
||||
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo " ✅ Branch '$BRANCH' criada no Gitea!"
|
||||
echo ""
|
||||
echo " PRÓXIMOS PASSOS:"
|
||||
echo " 1. Revisar as mudanças no Gitea"
|
||||
echo " https://git.homelabds.com.br/diegods/$REPO_NAME"
|
||||
echo " 2. Testar em ambiente de desenvolvimento"
|
||||
echo " 3. Fazer merge na master quando aprovado"
|
||||
echo " git checkout master && git merge $BRANCH && git push origin master"
|
||||
echo "============================================"
|
||||
Reference in New Issue
Block a user