From ee52080ebafc11bab21b9251e40e445bb545e021 Mon Sep 17 00:00:00 2001 From: Mirek SIC Date: Wed, 18 Mar 2026 22:42:13 +0100 Subject: [PATCH] Initial commit: KSEF PDF Generator from GitHub --- git-init.sh | 75 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/git-init.sh b/git-init.sh index 35462fa..5fa78c0 100755 --- a/git-init.sh +++ b/git-init.sh @@ -1,22 +1,37 @@ #!/bin/bash # Skrypt commitowania projektu na Gitea -# Użycie: ./git-init.sh [gitea_user] [gitea_repo] +# Użycie: ./git-init.sh [gitea_user] [gitea_password] [gitea_repo] set -e -set -x +# set -x # Odkomentuj dla debugowania # Parametry GITEA_USER="${1:-ms}" -GITEA_REPO="${2:-ksef-pdf-generator}" -GITEA_URL="https://10.1.1.1:30008/${GITEA_USER}/${GITEA_REPO}.git" +GITEA_PASS="${2:-}" +GITEA_REPO="${3:-ksef-pdf-generator}" +GITEA_HOST="10.1.1.1:30008" +GITEA_URL="https://${GITEA_USER}:${GITEA_PASS}@${GITEA_HOST}/${GITEA_USER}/${GITEA_REPO}.git" +GITEA_URL_DISPLAY="https://${GITEA_HOST}/${GITEA_USER}/${GITEA_REPO}.git" # Kolory YELLOW='\033[1;33m' GREEN='\033[0;32m' +RED='\033[0;31m' NC='\033[0m' +# Sprawdzenie hasła +if [ -z "$GITEA_PASS" ]; then + echo -e "${RED}❌ Error: Gitea password required${NC}" + echo "Użycie: ./git-init.sh [user] [password] [repo]" + echo "" + echo "Przykład: ./git-init.sh ms YOUR_PASSWORD ksef-pdf-generator" + exit 1 +fi + echo -e "${YELLOW}🚀 Git initialization for Gitea${NC}" -echo "Gitea URL: $GITEA_URL" +echo "Host: https://${GITEA_HOST}" +echo "User: ${GITEA_USER}" +echo "Repo: ${GITEA_REPO}" echo "" # Krok 1: Konfiguracja git (ignorowanie cert dla self-signed) @@ -24,6 +39,7 @@ echo -e "${YELLOW}1️⃣ Configuring git...${NC}" git config --global http.sslVerify false git config user.name "Mirek SIC" git config user.email "mirek@sic.pl" +git config --global credential.helper store # Cache credentials echo -e "${GREEN}✓ Git configured${NC}" echo "" @@ -44,8 +60,9 @@ if git remote | grep -q origin; then echo "Removing existing origin..." git remote remove origin fi +# Używaj URL z hasłem dla push, ale wyświetlaj bez hasła git remote add origin "$GITEA_URL" -echo -e "${GREEN}✓ Remote added: $GITEA_URL${NC}" +echo -e "${GREEN}✓ Remote added: $GITEA_URL_DISPLAY${NC}" echo "" # Krok 4: Stage i commit @@ -55,28 +72,40 @@ git commit -m "Initial commit: KSEF PDF Generator from GitHub" --allow-empty || echo -e "${GREEN}✓ Changes committed${NC}" echo "" -# Krok 5: Push do Gitea +# Krok 5: Push do Gitea (z timeout) echo -e "${YELLOW}5️⃣ Pushing to Gitea...${NC}" -git push -u origin main 2>&1 || ( +echo "Uwaga: pierwsze push może potrwać kilka sekund..." + +if timeout 60 git push -u origin main 2>&1; then + echo -e "${GREEN}✓ Push successful${NC}" echo "" - echo -e "${YELLOW}⚠️ Push failed. Debug info:${NC}" - echo "URL: $GITEA_URL" - echo "Credentials: mirek@sic.pl" + echo -e "${GREEN}✅ Git setup complete!${NC}" + echo "" + echo "Repository: $GITEA_URL_DISPLAY" + echo "" + echo "Dalsze komendy:" + echo " git status" + echo " git log --oneline" + echo " git push origin main" + echo " git pull origin main" +else + EXIT_CODE=$? + echo "" + if [ $EXIT_CODE -eq 124 ]; then + echo -e "${RED}❌ Error: Push timeout (60 sekund)${NC}" + else + echo -e "${RED}❌ Error: Push failed (exit code: $EXIT_CODE)${NC}" + fi + echo "" + echo "Debug info:" + echo " URL: $GITEA_URL_DISPLAY" + echo " User: $GITEA_USER" echo "" echo "Opcje debugowania:" - echo " GIT_TRACE=1 git push -u origin main" + echo " GIT_TRACE=1 ./git-init.sh $GITEA_USER $GITEA_PASS $GITEA_REPO" echo " git remote -v" + echo " git log --oneline" exit 1 -) -echo -e "${GREEN}✓ Push successful${NC}" -echo "" - -echo -e "${GREEN}✅ Git setup complete!${NC}" -echo "" -echo "Repository: $GITEA_URL" -echo "" -echo "Dalsze komendy:" -echo " git status" -echo " git log --oneline" +fi echo " git push origin main" echo " git pull origin main"