0

I'm writing a pre-commit hook to make sure commits to specific branches fullfill certain criterias. To do this, I need to find out the target branch of the commit.

I am using a Windows batch file that calls a Python script. I am using a SVN Python bindings api, which is badly documented. The source code can be found here in the Python zip file: http://sourceforge.net/projects/win32svn/files/1.7.8/apache24/. Just so you know which api I mean.

I found another question about this topic: SVN Pre-commit hook for avoiding commits to specific branches. However, I don't really understand the answer and don't know how I could achieve this with tools I have available and Python.

Community
  • 1
  • 1
Teemu Leivo
  • 341
  • 1
  • 4
  • 20
  • Are you already using path-based authorization? – Josh Jun 07 '13 at 15:17
  • No, I don't think so. Could it be a solution? – Teemu Leivo Jun 07 '13 at 15:21
  • path-based authorization is a common way to control access, versus putting ACL code into hook scripts. See [http://svnbook.red-bean.com/en/1.7/svn.serverconfig.pathbasedauthz.html](http://svnbook.red-bean.com/en/1.7/svn.serverconfig.pathbasedauthz.html) – Josh Jun 07 '13 at 15:25
  • Thanks for the tip. But actually, I realized I had presented my question badly. The idea is not to totally block commmits to some branches and allow them to others. But just check that commits to those specific branches are of "good quality". I edited this to the question. – Teemu Leivo Jun 07 '13 at 15:35

1 Answers1

1

I have a Perl hook that's already written that does exactly what you want.

You specify who can commit where by creating a control file:

[FILE All developers can commit to the trunk]
match=/trunk/**
access=read-write
users=@ALL

[FILE All branches are locked. You do not have access to them]
match=/branches/**
access=read-only
users=@ALL

[FILE Only bob and carol can commit to the 3.2 branch]
match/branches/3.2/**
access=read-write
users=bob,carol

You can also create groups, and use those:

[GROUP branch-committers]
users=bob,carol

[FILE Only the branch-committers can commit to the 3.2 branch]
match/branches/3.2/**
access=read-write
users=@branch-committers

And, if you install Perl's Net::LDAP module on your Subversion server, you can use your Windows Active Directory groups.

Perl is open source and free for Windows from either Strawberry Perl or Active State.

David W.
  • 105,218
  • 39
  • 216
  • 337