SVN pre-commit hook for avoiding changes to tags subdirectories

前端 未结 11 713
陌清茗
陌清茗 2020-11-28 04:25

Is there anybody who has clear instructions on how to add a pre-commit hook that avoids changes to tags subdirectories?

I already searched the internet quite a bit.

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 05:03

    The listed answers are great but none did exactly what I need. I want to allow creating tags easily, but once they are created they should be fully read-only.

    I also want to prevent the stupid situation where if you do this:

    svn copy myrepo/trunk myrepo/tags/newrelease
    

    All is well the first time. But the second time, if the tag already exists, you will end up with myrepo/tags/newrelease/trunk.

    My pre-commit hook will look for any pre-existing SVN directory matching (repo)/tags/(tag)/ and fail if it's found:

    $SVNLOOK tree -N --full-paths "$REPOS" "`$SVNLOOK changed -t "$TXN" "$REPOS" \
      | sed 's/[A-Z][[:space:]]*\([^/]*\)\/tags\/\([^/]*\)\/.*/\1\/tags\/\2\//' \
      | head -n 1`" \
      && echo "Tag already exists, commit rejected." >&2 \
      && exit 1
    

提交回复
热议问题