Skip to content
Permalink
Browse files

add some git support

git-svn-id: http://svn.osgeo.org/qgis/trunk@14691 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 16, 2010
1 parent 3992721 commit 7ab2de6b639e90c8bc39feb99d74751a0b72d73b
Showing with 44 additions and 16 deletions.
  1. +29 −13 CMakeLists.txt
  2. +15 −3 scripts/prepare-commit.sh
@@ -429,33 +429,49 @@ LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src/core ${CMAKE_BINARY_DIR}/src/gui)
# create qgssvnversion.h

FIND_FILE(SVN_MARKER entries PATHS ${CMAKE_SOURCE_DIR}/.svn)
FIND_FILE(GIT_MARKER index PATHS ${CMAKE_SOURCE_DIR}/.git)

IF (SVN_MARKER)
# See if we have svn installed
FIND_PROGRAM(SVNVERSION svnversion PATHS c:/cygwin/bin)

IF(SVNVERSION)
IF(MSVC)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
COMMAND for /f usebackq %%a in "(`\"${SVNVERSION}\"`)" do echo \#define QGSSVNVERSION \"%%a\" >${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
MAIN_DEPENDENCY ${SVN_MARKER}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
COMMAND for /f usebackq %%a in "(`\"${SVNVERSION}\"`)" do echo \#define QGSSVNVERSION \"%%a\" >${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
MAIN_DEPENDENCY ${SVN_MARKER}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ELSE(MSVC)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
COMMAND echo \\\#define QGSSVNVERSION \\\"`${SVNVERSION}`\\\" >${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
MAIN_DEPENDENCY ${SVN_MARKER}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
COMMAND echo \\\#define QGSSVNVERSION \\\"`${SVNVERSION}`\\\" >${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
MAIN_DEPENDENCY ${SVN_MARKER}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ENDIF(MSVC)
ELSE(SVNVERSION)
MESSAGE(STATUS "svnversion not found - version will be unknown")
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h "#define QGSSVNVERSION \"unknown\"")
ENDIF (SVNVERSION)
ELSE (SVN_MARKER)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h "#define QGSSVNVERSION \"exported\"")
IF (GIT_MARKER)
FIND_PROGRAM(GIT git PATHS c:/cygwin/bin)
IF(GIT)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
COMMAND echo \\\#define QGSSVNVERSION \\\"`${GIT} svn info | sed -ne "s/Revision: //p"`\\\" >${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
MAIN_DEPENDENCY ${GIT_MARKER}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ELSE(GIT)
MESSAGE(STATUS "git marker, but no git found - version will be unknown")
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h "#define QGSSVNVERSION \"unknown\"")
ENDIF(GIT)
ELSE (GIT_MARKER)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h "#define QGSSVNVERSION \"exported\"")
ENDIF (GIT_MARKER)
ENDIF (SVN_MARKER)

ADD_CUSTOM_TARGET(svnversion ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h)
@@ -17,16 +17,28 @@ fi
set -e

# determine changed files
MODIFIED=$(svn status | sed -ne "s/^[MA] *//p")
if [ -d .svn ]; then
MODIFIED=$(svn status | sed -ne "s/^[MA] *//p")
elif [ -d .git ]; then
MODIFIED=$(git status | sed -rne "s/^# (modified|new file): *//p")
else
echo No working copy
exit 1
fi

if [ -z "$MODIFIED" ]; then
echo nothing was modified
exit 1
fi

# save original changes
REV=$(svn info | sed -ne "s/Revision: //p")
svn diff >r$REV.diff
if [ -d .svn ]; then
REV=$(svn info | sed -ne "s/Revision: //p")
svn diff >r$REV.diff
elif [ -d .git ]; then
REV=$(git svn info | sed -ne "s/Revision //p")
git diff >r$REV.diff
fi

ASTYLEDIFF=astyle.r$REV.diff
>$ASTYLEDIFF

0 comments on commit 7ab2de6

Please sign in to comment.
You can’t perform that action at this time.