How do I keep an svn:external up to date using git-svn?

后端 未结 8 2258
广开言路
广开言路 2020-12-02 06:44

Treating my repository as a SVN repo, I get:

svn co http://myrepo/foo/trunk foo
...
foo/
  bar/
  baz/ -> http://myrepo/baz/trunk

Treati

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 07:16

    I just wrote a short script which checkouts all svn:externals of the current HEAD to the root directory and excludes them from the git repository.

    Place it to .git/hooks/post-checkout and it will keep those external checkouts up to date whenever the working tree changes, for example due to git svn rebase or git-checkout.

    #!/bin/bash
    set -eu
    
    revision=$(git svn info | sed -n 's/^Revision: \([1-9][0-9]*\)$/\1/p')
    git svn -r${revision} propget svn:externals | head -n-1 | {
        while read checkout_args
        do
            checkout_dirname=$(echo ${checkout_args} | cut -d' ' -f3)
            svn checkout ${checkout_args}
            if [ -z $(grep ${checkout_dirname} .git/info/exclude) ]
            then
                echo ${checkout_dirname} >> .git/info/exclude
            fi
        done
    }
    

提交回复
热议问题