here's a first draft of adding git support to scripty. I've tried to keep all the svn code the same; the only nonessential change here was doing a cd $mod once instead of multiple times (this should only change behaviour if a module is a directory but cannot be entered, which seems very unlikely).
there are some issues with the code as it stands: -if git checkout fails (which I'm not sure would ever happen), it may abort, in order to avoid doing things with the wrong branch of that module. I don't like that. I'm thinking it'd be better to remove that module from $releases and then patch findfiles to take a list of modules instead of getting that itself. -I'm not sure if I should rebase when I pull, just in case strange things have happened to the git repo. maybe only if the first pull fails? -I don't know whether we're going to keep using SVN_SILENT in git commit messages :) -any git push will fail until the git repo is one scripty has full access to. git.kde.org would be nice, although I'd also be fine with giving scripty a gitorious account for now. -I only have a little experience with git, so I might have overlooked some details. code review would be appreciated :) other than that, the rest of it should theoretically work. :) I've tested bits of the logic (like that line using cut -c3-) but haven't tried to actually run makemessages on my own machine. -- This message brought to you by eevil bananas and the number 3. www.chani3.com
Index: get_paths
===================================================================
--- get_paths (revision 965379)
+++ get_paths (working copy)
@@ -45,6 +45,8 @@
phonon)
echo trunk/kdesupport/phonon
;;
+ git-test)
+ echo git/git-test
*)
echo "ERROR: unknown module $1"
exit 1
@@ -63,3 +65,37 @@
;;
esac
}
+
+function get_vcs
+{
+ case "$1" in
+ git-test)
+ echo git
+ ;;
+ *)
+ echo svn
+ ;;
+ esac
+}
+
+#TODO pick a naming scheme
+function get_git_branch
+{
+ echo "master"
+}
+
+#TODO give scripty permission to push/pull the repo
+function get_url
+{
+ case "$1" in
+ git-test)
+ echo "[email protected]:scripty-with-git/git-test.git"
+ ;;
+ *)
+ echo "ERROR: $1 is not a git repo"
+ exit 1
+ ;;
+ esac
+}
+
+
Index: update_translations
===================================================================
--- update_translations (revision 965379)
+++ update_translations (working copy)
@@ -47,45 +47,94 @@
test -z "$TIMING1" || date
for i in qt-copy $releases l10n; do
- test -z "$NOUPDATE" || continue
+ vcs=`get_vcs $i`
+ if test -z "$NOUPDATE"; then
+ if test "$vcs" = git; then
+ branch=`get_git_branch $i`
+ i=`get_path $i`
+ git checkout $SVNQUIETFLAG $branch || echo "WARNING: failed to switch to $branch in $i, Bad Things may happen"
+ fi
+ continue
+ fi
test -z "$VERBOSE1" || echo "updating $i"
+ modname=$i
i=`get_path $i`
if test ! -d $i; then
mkdir -p $i
- svn co -q $SVNROOT/$i $i || echo "ERROR: checking out $i has failed!"
+ case "$vcs" in
+ svn)
+ svn co -q $SVNROOT/$i $i || echo "ERROR: checking out $i has failed!"
+ ;;
+ git)
+ git clone `get_url $modname` $i || echo "ERROR: checking out $i has failed!"
+ ;;
+ *)
+ echo "ERROR: unexpected VCS type?!"
+ ;;
+ esac
fi
if cd $i; then
### TODO: perhaps we could combine cleanup/svn-clean/revert (One svn stat -u, if it fails cleanup and revert are called, otherwise only svn-cleanup is done.)
if test -z "$NO_INITIAL_CLEANUP"; then
- svn cleanup .
- if test "$i" = "l10n"; then
- svn cleanup scripts/admin
- # Cleanup the external documentation directories of l10n
- if cd documentation; then
- for $docdir in *
- do
- svn cleanup $docdir
- done
- cd ..
- else
- echo "Could not find l10n/documentation"
- fi
- elif test -d admin; then
- svn cleanup admin
- fi
- perl $kdebasedir/kdesdk/scripts/svn-clean -f | fgrep -v "Subversion working directory" | grep -v '^F'
- test -z "$VERBOSE1" || echo
- # revert all changes, so that the following "svn update" is without conflicts
- svn revert $SVNQUIETFLAG -R .
- if test -d admin; then
- svn revert $SVNQUIETFLAG -R admin
- fi
- ### TODO: do we need to revert the external directories of l10n too? (Are we modifying them at all?)
+ case "$vcs" in
+ svn)
+ svn cleanup .
+ if test "$i" = "l10n"; then
+ svn cleanup scripts/admin
+ # Cleanup the external documentation directories of l10n
+ if cd documentation; then
+ for $docdir in *
+ do
+ svn cleanup $docdir
+ done
+ cd ..
+ else
+ echo "Could not find l10n/documentation"
+ fi
+ elif test -d admin; then
+ svn cleanup admin
+ fi
+ perl $kdebasedir/kdesdk/scripts/svn-clean -f | fgrep -v "Subversion working directory" | grep -v '^F'
+ test -z "$VERBOSE1" || echo
+ # revert all changes, so that the following "svn update" is without conflicts
+ svn revert $SVNQUIETFLAG -R .
+ if test -d admin; then
+ svn revert $SVNQUIETFLAG -R admin
+ fi
+ ### TODO: do we need to revert the external directories of l10n too? (Are we modifying them at all?)
+ ;;
+ git)
+ git clean -dfx $SVNQUIETFLAG
+ git reset --hard $SVNQUIETFLAG origin #this is a bit harsh; do we really want to nuke any local commits?
+ ;;
+ *)
+ echo "ERROR: unexpected VCS type?!"
+ ;;
+ esac
fi # test -z $NO_INITIAL_CLEANUP
+
test -z "$VERBOSE1" || echo
- svn update $SVNQUIETFLAG || echo "ERROR: module $i was not correctly updated"
+ case "$vcs" in
+ svn)
+ svn update $SVNQUIETFLAG || echo "ERROR: module $i was not correctly updated"
+ git)
+ branch=`get_git_branch $modname`
+ if ! git branch | cut -c3- | grep -q "^$branch$"; then
+ git branch --track $branch origin/$branch
+ fi
+ if ! git checkout $SVNQUIETFLAG $branch; then
+ echo "ERROR: failed to switch to branch $branch for module $modname."
+ exit 1 #FIXME I'd rather gracefully skip this module. but how?
+ #perhaps I could filter $releases. findfiles could be trouble though.
+ fi
+ #FIXME rebase just in case?
+ git pull $SVNQUIETFLAG || echo "ERROR: module $i was not correctly updated"
+ *)
+ echo "ERROR: unexpected VCS type?!"
+ ;;
+ esac
cd $BASEDIR
else
echo "ERROR: could not enter directory $i ! The module's update is SKIPPED!"
@@ -116,7 +165,7 @@
logmod=$templatename
mod=`get_path $templatename`
rm -rf /tmp/cvslog.$logmod
- if test -d $mod; then
+ if cd $BASEDIR/$mod; then
qtonly=`qt_only $templatename`
if test x"$qtonly" = x"yes"; then
@@ -128,7 +177,7 @@
echo "creating templates directory for $templatename"
mkdir $BASEDIR/backup/templates/messages/$templatename
svn mkdir $templatename
- cd $BASEDIR
+ cd $BASEDIR/$mod
else
echo "SKIPPING $mod - no template directory!"
continue
@@ -136,28 +185,41 @@
fi
test -z "$VERBOSE1" || echo "making messages in $mod"
- if test ! -d $mod/po; then
- ln -s $BASEDIR/$transmod/templates/messages/$templatename $mod/po
+ if test ! -d po; then
+ ln -s $BASEDIR/$transmod/templates/messages/$templatename po
fi
- ls -d $mod/po
+ ls -d po
+
+ vcs=`get_vcs $logmod`
- (cd $mod && XGETTEXT=`which xgettext` \
+ ( XGETTEXT=`which xgettext` \
EXTRACTRC="perl $extractrc --ignore-no-input" \
EXTRACTATTR="perl $extractattr" \
PREPARETIPS="perl $preparetips" \
REPACKPOT="perl $repackpot" \
PACKAGE=$mod \
+ IGNORE=".$vcs" \
bash $BASEDIR/$transmod/scripts/extract-messages.sh)
- rm -f $mod/messages.log
+ rm -f messages.log
- (cd $mod && XGETTEXT=`which xgettext` \
+ ( XGETTEXT=`which xgettext` \
PACKAGE=$mod \
bash $BASEDIR/$transmod/scripts/extract-xml.sh)
- rm -f $mod/messages.log
+ rm -f messages.log
- (cd $mod &&
- svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (after extraction)" > /dev/null)
- if cd $transmod/templates/messages/$templatename ; then
+ case "$vcs" in
+ svn)
+ svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (after extraction)" > /dev/null
+ git)
+ #FIXME what'll the equivalent of SVN_SILENT be?
+ #also, I'm 99% sure there's nothing to commit
+ git commit -a $SVNQUIETFLAG -m "SVN_SILENT made messages (after extraction)"
+ git push
+ *)
+ echo "ERROR: unexpected VCS type?!"
+ ;;
+ esac
+ if cd $BASEDIR/$transmod/templates/messages/$templatename ; then
for i in *.pot; do
if test ! -f $i; then continue; fi
if test ! -f $BASEDIR/backup/templates/messages/$templatename/$i ; then
@@ -176,10 +238,10 @@
cp -f $i $BASEDIR/backup/templates/messages/$templatename/$i
fi
done
- cd $BASEDIR
+ cd $BASEDIR/$mod
fi
- rm -rf $mod/po.backup
- if test -L $mod/po; then rm -f $mod/po; fi
+ rm -rf po.backup
+ if test -L po; then rm -f po; fi
fi
done
@@ -374,15 +436,32 @@
test -z "$TIMING1" || date
for i in $releases l10n; do
if cd $BASEDIR/`get_path $i`; then
- if ! svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file)" > /dev/null; then
- # If the commit fails, then it means that a file was modified. Normally it will not be a .desktop file
- echo "Need to update $i"
- svn update $SVNQUIETFLAG
- if ! svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file, second try)"; then
- echo "ERROR: commiting .desktop files failed for module $i!"
- svn revert -R .
- fi
- fi
+ vcs=`get_vcs $i`
+ case "$vcs" in
+ svn)
+ if ! svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file)" > /dev/null; then
+ # If the commit fails, then it means that a file was modified. Normally it will not be a .desktop file
+ echo "Need to update $i"
+ svn update $SVNQUIETFLAG
+ if ! svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file, second try)"; then
+ echo "ERROR: commiting .desktop files failed for module $i!"
+ svn revert -R .
+ fi
+ fi
+ git)
+ git commit -a $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file)"
+ if ! git push > /dev/null; then
+ echo "Need to update $i"
+ git pull $SVNQUIETFLAG
+ if ! git push; then
+ echo "ERROR: commiting .desktop files failed for module $i!"
+ git reset --hard $SVNQUIETFLAG origin
+ fi
+ fi
+ *)
+ echo "ERROR: unexpected VCS type?!"
+ ;;
+ esac
fi
done
else
Index: extract-messages.sh
===================================================================
--- extract-messages.sh (revision 965379)
+++ extract-messages.sh (working copy)
@@ -9,6 +9,7 @@
PREPARETIPS=${PREPARETIPS:-preparetips}
REPACKPOT=${REPACKPOT:-repack-pot.pl}
export EXTRACTRC EXTRACTATTR PREPARETIPS REPACKPOT
+IGNORE=${IGNORE:-.svn}
for subdir in $dirs; do
# skip Messages.sh files of KDevelop's app templates
@@ -17,7 +18,7 @@
test -z "$VERBOSE" || echo "Making messages in $subdir"
(cd $subdir
ls -1 *.rc *.ui *.ui3 *.ui4 *.kcfg 2> /dev/null | xargs --no-run-if-empty $EXTRACTRC > rc.cpp
- if find . -name \*.c\* -o -name \*.h\* | fgrep -v ".svn" | xargs fgrep -s -q KAboutData ; then
+ if find . -name \*.c\* -o -name \*.h\* | fgrep -v "$IGNORE" | xargs fgrep -s -q KAboutData ; then
echo 'i18nc("NAME OF TRANSLATORS","Your names");' >> rc.cpp
echo 'i18nc("EMAIL OF TRANSLATORS","Your emails");' >> rc.cpp
fi
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Kde-scm-interest mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-scm-interest
