diff --git a/gitea_push.sh b/gitea_push.sh deleted file mode 100755 index b722955..0000000 --- a/gitea_push.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -echo "πŸ“ IngresΓ‘ el directorio del proyecto:" -read -r PROJECT_DIR - -if [ ! -d "$PROJECT_DIR" ]; then - echo "❌ El directorio no existe. Abortando." - exit 1 -fi - -cd "$PROJECT_DIR" || exit - -# Inicializar Git si no existe -if [ ! -d ".git" ]; then - echo "πŸ”§ Inicializando repositorio Git local..." - git init - git branch -m main -fi - -# Agregar archivos -git add . - -echo "πŸ“ IngresΓ‘ el mensaje del commit:" -read -r COMMIT_MSG - -git commit -m "$COMMIT_MSG" - -# Configurar remoto -echo "🌐 IngresΓ‘ la URL del repositorio remoto en Gitea (HTTPS):" -read -r REMOTE_URL - -git remote remove origin 2>/dev/null -git remote add origin "$REMOTE_URL" - -# AutenticaciΓ³n -echo "πŸ” IngresΓ‘ tu usuario de Gitea:" -read -r USER - -echo "πŸ” IngresΓ‘ tu contraseΓ±a o token de Gitea:" -read -rs PASS - -# Push -echo "πŸš€ Subiendo archivos..." -git push -u https://"$USER":"$PASS"@"${REMOTE_URL#https://}" main diff --git a/instalar-subir.sh b/instalar-subir.sh new file mode 100755 index 0000000..3e4f63c --- /dev/null +++ b/instalar-subir.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +# ╔════════════════════════════════════════════════════╗ +# β•‘ VERIFICACIΓ“N DE REPOSITORIO GIT β•‘ +# β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• + +if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + echo "" + echo "πŸ›‘ Este comando debe ejecutarse dentro de un repositorio Git." + exit 1 +fi + +BRANCH="main" + +# ╔════════════════════════════════════════════════════╗ +# β•‘ INGRESO DE CREDENCIALES β•‘ +# β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• + +echo "" +echo "πŸ” IngresΓ‘ tu usuario de Gitea:" +echo "╔════════════════╗" +read -p "β•‘ Usuario: " USER +echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•" + +echo "" +echo "πŸ” IngresΓ‘ tu contraseΓ±a o token de Gitea:" +echo "╔════════════════════════════════╗" +read -s -p "β•‘ ContraseΓ±a/Token: " TOKEN +echo "" +echo "β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•" + +# ╔════════════════════════════════════════════════════╗ +# β•‘ DETECCIΓ“N DE CAMBIOS SIN COMMITEAR β•‘ +# β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• + +CHANGES=$(git status --porcelain) + +if [ -n "$CHANGES" ]; then + echo "" + echo "πŸ“¦ Se detectaron cambios sin commitear:" + echo "$CHANGES" + read -p "ΒΏQuerΓ©s hacer commit automΓ‘tico de estos cambios? (s/n): " COMMIT_RESP + + if [ "$COMMIT_RESP" == "s" ]; then + echo "" + read -p "πŸ“ IngresΓ‘ el mensaje de commit: " COMMIT_MSG + git add . + git commit -m "$COMMIT_MSG" + echo "βœ… Commit realizado." + else + echo "πŸ›‘ No se hizo commit. Continuando sin cambios." + fi +fi + +# ╔════════════════════════════════════════════════════╗ +# β•‘ INICIO DE SUBIDA DE ARCHIVOS β•‘ +# β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• + +echo "" +echo "πŸš€ Subiendo archivos al repositorio remoto..." +echo "" + +REPO_URL=$(git config --get remote.origin.url) + +git config --global credential.helper store +echo "${REPO_URL/https:\/\//https://$USER:$TOKEN@}" > ~/.git-credentials + +git push origin $BRANCH +if [ $? -ne 0 ]; then + echo "" + echo "⚠️ Push fallido. Intentando pull con --allow-unrelated-histories..." + git pull origin $BRANCH --allow-unrelated-histories + + if [ $? -eq 0 ]; then + echo "" + echo "βœ… Pull exitoso. Reintentando push..." + git push origin $BRANCH + else + echo "" + echo "⚠️ Verificando conflictos..." + CONFLICTS=$(git diff --name-only --diff-filter=U) + + if [ -n "$CONFLICTS" ]; then + echo "" + echo "🚨 Conflictos detectados:" + echo "$CONFLICTS" + read -p "ΒΏHacer merge automΓ‘tico? (s/n): " RESP + if [ "$RESP" == "s" ]; then + git add . + git commit -m "πŸ”€ Merge automΓ‘tico" + git push origin $BRANCH + echo "πŸŽ‰ Push completado despuΓ©s del merge." + else + echo "πŸ›‘ Merge cancelado. ResolvΓ© manualmente." + fi + else + echo "❌ Pull fallΓ³ por otro motivo." + fi + fi +fi