git2darcs.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. set -e
  3. PREFIX=/usr/local/bin
  4. GIT=$PREFIX/git
  5. DARCS=$PREFIX/darcs
  6. [ -d _darcs -a -d .git ] || exit 1
  7. TMPDIR=/tmp/git2darcs
  8. [ -d $TMPDIR -a -w $TMPDIR ] || mkdir -p $TMPDIR || exit 1
  9. HEAD=`$GIT rev-list --no-walk --pretty=%H HEAD | tail -1`
  10. # Nur fast-forward kompatible commits ziehen,
  11. # um keine Konflikte ins darcs zu recorden.
  12. # Im laufenden Betrieb muss der master branch
  13. # des git upstreams also "sauber" bleiben.
  14. # XXX Fehlermeldung per mail o.dgl. hinter das git pull bauen.
  15. $GIT pull --ff-only --all
  16. FETCH_HEAD=`$GIT rev-list --no-walk --pretty=%H FETCH_HEAD | tail -1`
  17. [ -n "$HEAD" -a -n "$FETCH_HEAD" ] && [ "$HEAD" = "$FETCH_HEAD" ] && exit 0
  18. NEW_COMMITS="$HEAD..$FETCH_HEAD"
  19. $GIT rev-list --reverse --no-walk "$NEW_COMMITS" > $TMPDIR/rev-list
  20. [ -s $TMPDIR/rev-list ]
  21. sed -n -E -e 's@^(.+)$@'"$GIT"' reset --hard \1 \&\& '"$GIT"' rev-list --no-walk --pretty=\"%s%n%-b%n%ad %H\" \1 \| tail +2 > '"$TMPDIR/body"' \&\& '"$GIT"' rev-list --no-walk --pretty=format:\"'"$DARCS"' record --all --look-for-adds --logfile='"$TMPDIR/body"' --author \\\"%an <%ae>\\\"\" \1 | tail +2 > '"$TMPDIR/git2darcs.darcs.sh"' \&\& sh '"$TMPDIR/git2darcs.darcs.sh"'@p' $TMPDIR/rev-list > $TMPDIR/git2darcs.sh
  22. sh $TMPDIR/git2darcs.sh
  23. rm -rf $TMPDIR