From b9cf0cd1b434864426cc30a724cdc6751934429e Mon Sep 17 00:00:00 2001 From: Juan Date: Wed, 29 Aug 2018 15:56:12 +0200 Subject: [PATCH] Test --- config | 3 +++ debian/changelog | 2 +- debian/install | 1 + vn-branch | 22 ++++++++++++++++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100755 config diff --git a/config b/config new file mode 100755 index 0000000..d4bba8b --- /dev/null +++ b/config @@ -0,0 +1,3 @@ +#!/bin/bash + +gitUrl=https://git.verdnatura.es \ No newline at end of file diff --git a/debian/changelog b/debian/changelog index 2bd355b..469787c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -vn-repo (2.0.37) stable; urgency=low +vn-repo (2.0.38) stable; urgency=low * Initial Release. diff --git a/debian/install b/debian/install index 7d39cfd..29f8bed 100644 --- a/debian/install +++ b/debian/install @@ -1,4 +1,5 @@ vn-repo.conf etc/apache2/conf-available +config etc/vn-repo git-hooks usr/share/vn-repo web usr/share/vn-repo vn-branch usr/bin diff --git a/vn-branch b/vn-branch index 831dc29..19342fe 100755 --- a/vn-branch +++ b/vn-branch @@ -6,6 +6,17 @@ if [ "$#" -eq "0" ]; then fi projectName=$1 +gitBranch=$2 + +. /etc/vn-repo/config + +if [ -z "$gitUrl" ]; then + gitUrl=http://localhost +fi +if [ -z "$gitBranch" ]; then + gitBranch=master +fi + repoDir="/var/lib/git/$projectName" srcDir="/tmp/vn-repo/$projectName/src" logDir="/usr/share/vn-repo/web/logs" @@ -21,10 +32,17 @@ echo " * Directory: $srcDir" >> "$logFile" echo " * Host: $(hostname)" >> "$logFile" mkdir -p "$srcDir" -git --work-tree="$srcDir" --git-dir="$repoDir" checkout -f +cd "$srcDir" + +if [ ! -d "$srcDir/.git" ]; then + git init +fi + +git config remote.origin.url "$gitUrl/$projectName" +git pull origin "$gitBranch" if [ -f "$srcDir/deploy" ]; then - (cd "$srcDir" && "$srcDir/deploy" >> "$logFile" 2>&1) + "$srcDir/deploy" >> "$logFile" 2>&1 fi echo -e "\n# Deploying ended\n" >> "$logFile"