You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by James CE Johnson <jc...@tragus.org> on 2008/05/16 18:20:47 UTC

Getting file content in pre-commit

Hi,

I have a need to capture the content of files being committed. Not to
change them but to analyze for one thing or another. For instance, we
might fail the commit if a file is too big or fails formatting rules (e.g.
-- source code) or for some other metric.

I've tried "svnlook cat ..." but since the file hasn't been committed yet
that doesn't show me the content of new files or the updated content of
changed files. I thought I might use a combination of cat/diff to create a
patch but that won't help me with binary files (so, failing large-file
commits).

Ideas?

Thanks,
James



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: [SVN] Re: Getting file content in pre-commit

Posted by James CE Johnson <jc...@tragus.org>.
It must be Monday and nobody told me...

I did, indeed, try 'svnlook cat' before posting and came up with the
vacuum of space for newly-added files. After a reimplementation inspired
by your comments all is working perfectly now.

For anyone who is also having a Monday on this Friday afternoon, here is
the partial solution in my pre-commit hook:

 for i in $(${SVNLOOK} changed -t ${TXN} ${REPOS} | grep '^[AU]')
 do
   echo "-- $i --"
   ${SVNLOOK} cat -t ${TXN} ${REPOS} $i
 done

Thanks Larry!

> svnlook cat will take the transaction (uncommitted) as well as a revision
> (committed already). Look at svnlook help cat
>
> You will need to get a list of the files in the transaction, so svnlook
> help
> changed will give you help.
>
> -- Larry
>
> On Fri, May 16, 2008 at 12:20 PM, James CE Johnson <jc...@tragus.org>
> wrote:
>
>> Hi,
>>
>> I have a need to capture the content of files being committed. Not to
>> change them but to analyze for one thing or another. For instance, we
>> might fail the commit if a file is too big or fails formatting rules
>> (e.g.
>> -- source code) or for some other metric.
>>
>> I've tried "svnlook cat ..." but since the file hasn't been committed
>> yet
>> that doesn't show me the content of new files or the updated content of
>> changed files. I thought I might use a combination of cat/diff to create
>> a
>> patch but that won't help me with binary files (so, failing large-file
>> commits).
>>
>> Ideas?
>>
>> Thanks,
>> James
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
>> For additional commands, e-mail: users-help@subversion.tigris.org
>>
>>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Getting file content in pre-commit

Posted by "Larry Shatzer, Jr." <la...@gmail.com>.
svnlook cat will take the transaction (uncommitted) as well as a revision
(committed already). Look at svnlook help cat

You will need to get a list of the files in the transaction, so svnlook help
changed will give you help.

-- Larry

On Fri, May 16, 2008 at 12:20 PM, James CE Johnson <jc...@tragus.org> wrote:

> Hi,
>
> I have a need to capture the content of files being committed. Not to
> change them but to analyze for one thing or another. For instance, we
> might fail the commit if a file is too big or fails formatting rules (e.g.
> -- source code) or for some other metric.
>
> I've tried "svnlook cat ..." but since the file hasn't been committed yet
> that doesn't show me the content of new files or the updated content of
> changed files. I thought I might use a combination of cat/diff to create a
> patch but that won't help me with binary files (so, failing large-file
> commits).
>
> Ideas?
>
> Thanks,
> James
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>