diff options
author | Miklos Vajna <vmiklos@frugalware.org> | 2010-03-17 01:09:30 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@frugalware.org> | 2010-03-17 01:09:30 +0100 |
commit | 41eee44fc238196007ad1b05c22a921f15d10341 (patch) | |
tree | e005c75aec2b79be9c1fc7eaeb0727df8ca16462 /exporters | |
parent | 879e2cc517353a82144912f3bc8c57aff9b39158 (diff) | |
download | bzr-fastimport-41eee44fc238196007ad1b05c22a921f15d10341.tar.gz |
git-darcs: add support for {pre,post}-{fetch,push} hooks
Diffstat (limited to 'exporters')
-rwxr-xr-x | exporters/darcs/git-darcs | 18 | ||||
-rw-r--r-- | exporters/darcs/git-darcs.txt | 19 |
2 files changed, 35 insertions, 2 deletions
diff --git a/exporters/darcs/git-darcs b/exporters/darcs/git-darcs index a8bfe8e..2272cd3 100755 --- a/exporters/darcs/git-darcs +++ b/exporters/darcs/git-darcs @@ -2,7 +2,7 @@ # # git-darcs - bidirectional operation between a darcs repo and git # -# Copyright (c) 2008 by Miklos Vajna <vmiklos@frugalware.org> +# Copyright (c) 2008, 2010 by Miklos Vajna <vmiklos@frugalware.org> # # Based on git-bzr, which is # @@ -78,6 +78,10 @@ fetch() darcs_map=$git_dir/darcs-git/$remote-darcs-map common_opts="--working $git_dir/darcs-git/repo --logfile $git_dir/darcs-git/fetch.log --git-branch=darcs/$remote" dfe_opts=$(git config git-darcs.$remote.darcs-fast-export-options) + pre_fetch="$(git config git-darcs.$remote.pre-fetch)" + if [ -n "$pre_fetch" ]; then + $pre_fetch + fi if [ ! -f $git_map -a ! -f $darcs_map ]; then echo "There doesn't seem to be an existing refmap." echo "Doing an initial import" @@ -101,6 +105,10 @@ fetch() echo "One of the mapfiles is missing! Something went wrong!" exit fi + post_fetch="$(git config git-darcs.$remote.post-fetch)" + if [ -n "$post_fetch" ]; then + $post_fetch + fi } pull() @@ -144,6 +152,10 @@ push() echo "We do not have refmapping yet. Then how can I push?" exit fi + pre_push="$(git config git-darcs.$remote.pre-push)" + if [ -n "$pre_push" ]; then + $pre_push + fi echo "Pushing the following updates:" git shortlog darcs/$remote.. git fast-export --import-marks=$git_map --export-marks=$git_map HEAD | \ @@ -151,6 +163,10 @@ push() --logfile $git_dir/darcs-git/push.log) if [ $? == 0 ]; then git update-ref darcs/$remote HEAD + post_push="$(git config git-darcs.$remote.post-push)" + if [ -n "$post_push" ]; then + $post_push + fi fi } diff --git a/exporters/darcs/git-darcs.txt b/exporters/darcs/git-darcs.txt index 7558329..eabd553 100644 --- a/exporters/darcs/git-darcs.txt +++ b/exporters/darcs/git-darcs.txt @@ -20,7 +20,7 @@ A typical workflow is: $ mkdir git-repo $ cd git-repo $ git init -$ git darcs add upstream ../darcs-repo +$ git darcs add upstream /path/to/darcs-repo $ git darcs pull upstream ... hack, hack, hack ... @@ -70,3 +70,20 @@ find-darcs:: find-git:: Searches for git commits matching a darcs patch prefix. The syntax is `find-git <patch-prefix>`. + +== HOOKS + +It's possible to automatically run before and after the fetch and the +push subcommand. For example if you want to automatically run `darcs +pull -a` before a `git darcs fetch upstream`: + +---- +git config git-darcs.upstream.pre-fetch "darcs pull -a --repodir=/path/to/darcs-repo" +---- + +Or in case you want to automatically `darcs send` all patches after a +`git darcs push upstream`: + +---- +git config git-darcs.upstream.post-push "darcs send -a --repodir=/path/to/darcs-repo" +---- |