From c504f8d6011a588374b79fb78fefc0c4413e3410 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Mon, 4 Mar 2013 22:35:40 +0100 Subject: [PATCH] Added support for git --- src/deforaos-release.sh | 91 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 6 deletions(-) diff --git a/src/deforaos-release.sh b/src/deforaos-release.sh index ca39d1d..c2a6346 100755 --- a/src/deforaos-release.sh +++ b/src/deforaos-release.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2012 Pierre Pronchery +#Copyright (c) 2012-2013 Pierre Pronchery #This file is part of DeforaOS Devel scripts #This program is free software: you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by @@ -24,10 +24,12 @@ PROJECTCONF="project.conf" VERBOSE=0 #executables CVS="cvs" +GIT="git" MAKE="make" RM="rm -f" TAR="tar" TR="tr" +WC="wc" #functions @@ -60,15 +62,14 @@ _deforaos_release() fi _info "Obtaining latest version..." - $DEBUG $CVS up -A + _release_fetch if [ $? -ne 0 ]; then _error "Could not update the sources" return $? fi _info "Checking for differences..." - #XXX this method may be obsoleted in a future version of CVS - $DEBUG $CVS diff + _release_diff if [ $? -ne 0 ]; then _error "The sources were modified" return $? @@ -103,8 +104,8 @@ _deforaos_release() tag=$(echo $version | $TR . -) tag="${PACKAGE}_$tag" _info "Tagging the sources as $tag..." - $DEBUG $CVS tag "$tag" - if [ $res -ne 0 ]; then + _release_tag "$tag" + if [ $? -ne 0 ]; then _error "Could not tag the sources" return $? fi @@ -119,6 +120,84 @@ _deforaos_release() _info " * package where appropriate (see deforaos-package.sh)" } +_release_diff() +{ + if [ -d "CVS" ]; then + _release_diff_cvs + return $? + elif [ -d ".git" ]; then + _release_diff_git + return $? + else + return 2 + fi +} + +_release_diff_cvs() +{ + #XXX this method may be obsoleted in a future version of CVS + $DEBUG $CVS diff +} + +_release_diff_git() +{ + lines=$($DEBUG $GIT diff | $WC -l) + [ $lines -eq 0 ] || return 2 +} + +_release_fetch() +{ + if [ -d "CVS" ]; then + _release_fetch_cvs + return $? + elif [ -d ".git" ]; then + _release_fetch_git + return $? + else + return 2 + fi +} + +_release_fetch_cvs() +{ + $DEBUG $CVS up -A +} + +_release_fetch_git() +{ + $DEBUG $GIT pull origin master +} + +_release_tag() +{ + tag="$1" + + if [ -d "CVS" ]; then + _release_tag_cvs "$tag" + return $? + elif [ -d ".git" ]; then + _release_tag_git "$tag" + return $? + else + return 2 + fi +} + +_release_tag_cvs() +{ + tag="$1" + + $DEBUG $CVS tag "$tag" +} + +_release_tag_git() +{ + tag="$1" + + $DEBUG $GIT tag "$tag" || return 2 + $DEBUG $GIT push --tags || return 2 +} + #debug _debug()