Domanda

Come creare uno script di hook del server Subversion che impedisca alle persone di apportare modifiche se non possiedono prima il blocco sul file?

Il server Svn è su Windows.

Grazie.

PSUlteriori informazioni in questa domanda

Subversion (svn + tortoiseSvn) commit file non bloccato

È stato utile?

Soluzione

Usa un hook pre-commit.L'hook pre-commit riceve 2 argomenti:

#   [1] REPOS-PATH   (the path to this repository)
#   [2] TXN-NAME     (the name of the txn about to be committed)

Devi usare svnlook per determinare se ci sono file svn:needs-lock che non sono bloccati.

Per determinare i percorsi modificati da questo commit:

svnlook changed $1 --transaction $2

Passa in rassegna i file ($PATH come elemento del ciclo) in 'modificato' e determina svn:needs-lock e se sono attualmente bloccati:

svnlook propget $REPOS-PATH svn:needs-lock $PATH
svnlook lock $1 $PATH

Scrivi un su stderr e restituisci un valore diverso da zero per interrompere questo commit quando necessario.

Altri suggerimenti

Puoi usare <your repos directory>/hooks/pre-commit e utilizzare alcuni script batch (o anche un programma completo, purché sia ​​eseguibile andrà bene).Se ritorna 0 il commit avrà successo;altrimenti fallirà.

Vedere post-lock.tmpl nella stessa directory per un esempio.

# PRE-COMMIT HOOK
#
# The pre-commit hook is invoked before a Subversion txn is
# committed.  Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
#
#   [1] REPOS-PATH   (the path to this repository)
#   [2] TXN-NAME     (the name of the txn about to be committed)
#
# The default working directory for the invocation is undefined, so
# the program should set one explicitly if it cares.
#
# If the hook program exits with success, the txn is committed; but
# if it exits with failure (non-zero), the txn is aborted, no commit
# takes place, and STDERR is returned to the client.   The hook
# program can use the 'svnlook' utility to help it examine the txn.
#
# On a Unix system, the normal procedure is to have 'pre-commit'
# invoke other programs to do the real work, though it may do the
# work itself too.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top