You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Fu-Tung Cheng <fu...@yahoo.com> on 2008/09/03 19:31:41 UTC
On commit, svn server to change line ending to unix style for .sh files.
Hi,
I would like the server to store files with the extension .sh as unix style line endings even if those files are written on windows and committed from windows.
When I checkout on windows the .sh files should be in unix format as I'd never want them in dos format.
Is there a way to set this on the server side?
Thank you,
Fu-Tung
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
RE: On commit, svn server to change line ending to unix style for .sh files.
Posted by Fu-Tung Cheng <fu...@yahoo.com>.
Thanks Giulio!
I might have to steal your script. It's too bad they don't have this as a server-side feature.
Fu-Tung
--- On Mon, 9/8/08, Giulio Troccoli <Gi...@uk.linedata.com> wrote:
> That's not totally true. It'd be better to say that
> it's not advisable to do so. However it is
> "technically" possible and I have implemented it
> (and exactly for the OP's issue).
>
> My post-commit hook checks for the svn:eol-style. If
> it's not defined then it sets it to LF. If it defined
> but it's not LF then it changes it to LF. Finally a
> commit is done. To do all this I use a special
> "admin" working copy I keep on the server.
> I've never had any problems with that so far.
>
> This is an extract of my post-commit hook (it's a Korn
> shell script)
>
> ##
> ## MAKE SURE THAT THE svn:eol-style PROPERTY IS SET TO LF
> ##
> cd $WC_ADMIN_PATH
> $SVN --quiet update src
>
> # Set the flag
> propset=0
>
> $SVNLOOK changed --revision $REVISION $REPOS_PATH | $AWK
> '{OFS=";"; print $1,$2}' >
> $TMPDIR/changes_list
> for line in `cat $TMPDIR/changes_list`; do
> status=`$ECHO $line | $CUT -d";" -f1`
> file=`$ECHO $line | $CUT -d";" -f2`
> # If the file is a new file
> if [ "$status" == "A" ]; then
> # Set the svn:eol-style property to 'LF'
> $SVN propset svn:eol-style "LF"
> $WC_ADMIN_BASE_PATH/$file
> propset=1
> # Send an email that a new file has been added
> $MAIL -s "New file in Subversion: $file"
> $BUILDMASTERS_EMAILS
> elif [ "$status" == "D" ]; then
> # Send an email that an old file has been deleted
> $MAIL -s "Old file in Subversion has been
> deleted: $file" $BUILDMASTERS_EMAILS
> else # If it's not a new file and it's not been
> deleted
> # Get the svn:eol-style property, which is the one we
> are interested in
> eolstyle=`$SVN propget svn:eol-style
> $WC_ADMIN_BASE_PATH/$file`
> # If svn:eol-style is not 'LF' then change it
> if [ "$eolstyle" != "LF" ]; then
> $SVN propset svn:eol-style "LF"
> $WC_ADMIN_BASE_PATH/$file
> propset=1
> fi
> fi
> done
>
> # Remove the temporary list of changes
> rm -f $TMPDIR/changes_list
>
> # If we have modified some properties then commit the
> changes
> if [ $propset -eq 1 ]; then
> cd src
> $SVN commit --message "OOP: Setting (or changing)
> svn:eol-style property to 'LF'"
> fi
>
> Giulio
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
RE: On commit, svn server to change line ending to unix style for .sh files.
Posted by Giulio Troccoli <Gi...@uk.linedata.com>.
>
Linedata Services (UK) Ltd
Registered Office: Bishopsgate Court, 4-12 Norton Folgate, London, E1 6DB
Registered in England and Wales No 3027851 VAT Reg No 778499447
-----Original Message-----
> From: David Weintraub [mailto:qazwart@gmail.com]
> Sent: 07 September 2008 03:52
> To: futung.cheng@yahoo.com
> Cc: users@subversion.tigris.org
> Subject: Re: On commit, svn server to change line ending to unix style for
> .sh files. [auto-ip]
>
> You can't
> really do this via server side. However, you can do this via the
> autoproperties in your config file. I setup a company wide config
> file, and after a few rejected commits, people are using it.
That's not totally true. It'd be better to say that it's not advisable to do so. However it is "technically" possible and I have implemented it (and exactly for the OP's issue).
My post-commit hook checks for the svn:eol-style. If it's not defined then it sets it to LF. If it defined but it's not LF then it changes it to LF. Finally a commit is done. To do all this I use a special "admin" working copy I keep on the server. I've never had any problems with that so far.
This is an extract of my post-commit hook (it's a Korn shell script)
##
## MAKE SURE THAT THE svn:eol-style PROPERTY IS SET TO LF
##
cd $WC_ADMIN_PATH
$SVN --quiet update src
# Set the flag
propset=0
$SVNLOOK changed --revision $REVISION $REPOS_PATH | $AWK '{OFS=";"; print $1,$2}' > $TMPDIR/changes_list
for line in `cat $TMPDIR/changes_list`; do
status=`$ECHO $line | $CUT -d";" -f1`
file=`$ECHO $line | $CUT -d";" -f2`
# If the file is a new file
if [ "$status" == "A" ]; then
# Set the svn:eol-style property to 'LF'
$SVN propset svn:eol-style "LF" $WC_ADMIN_BASE_PATH/$file
propset=1
# Send an email that a new file has been added
$MAIL -s "New file in Subversion: $file" $BUILDMASTERS_EMAILS
elif [ "$status" == "D" ]; then
# Send an email that an old file has been deleted
$MAIL -s "Old file in Subversion has been deleted: $file" $BUILDMASTERS_EMAILS
else # If it's not a new file and it's not been deleted
# Get the svn:eol-style property, which is the one we are interested in
eolstyle=`$SVN propget svn:eol-style $WC_ADMIN_BASE_PATH/$file`
# If svn:eol-style is not 'LF' then change it
if [ "$eolstyle" != "LF" ]; then
$SVN propset svn:eol-style "LF" $WC_ADMIN_BASE_PATH/$file
propset=1
fi
fi
done
# Remove the temporary list of changes
rm -f $TMPDIR/changes_list
# If we have modified some properties then commit the changes
if [ $propset -eq 1 ]; then
cd src
$SVN commit --message "OOP: Setting (or changing) svn:eol-style property to 'LF'"
fi
Giulio
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: On commit, svn server to change line ending to unix style for .sh files.
Posted by Fu-Tung Cheng <fu...@yahoo.com>.
Hi David,
Thank you for the response!
I'd love to have a look at your script! Please do send me a copy.
Fu-Tung
--- On Sun, 9/7/08, David Weintraub <qa...@gmail.com> wrote:
> From: David Weintraub <qa...@gmail.com>
> Subject: Re: On commit, svn server to change line ending to unix style for .sh files.
> To: futung.cheng@yahoo.com
> Cc: users@subversion.tigris.org
> Date: Sunday, September 7, 2008, 2:52 AM
> Take a look at the "svn:eol-style" property. That
> allows you to
> specify the line ending for a particular file.
>
> If your goal is to make sure all files that end in *.sh
> must have this
> property, you'll need to write a pre-commit hook script
> that allows
> you to do this.
>
> I do have such a script written in Perl, and will be happy
> to send it
> to you if you'd like. It's part of a script that
> also verifies write
> authorizations, protects tags from changes, and even allows
> you to
> prevent people from creating files that contain invalid
> characters.
>
> By the way, the pre-commit hook script will prohibit a
> commit if a
> *.sh doesn't have the svn:eol-style property set to
> "LF", but won't
> automatically add the svn:eol-style property to the file.
> You can't
> really do this via server side. However, you can do this
> via the
> autoproperties in your config file. I setup a company wide
> config
> file, and after a few rejected commits, people are using
> it.
>
> Properties:
> <http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.advanced.props>
> Autoproperties Config:
> <http://svnbook.red-bean.com/en/1.4/svn.advanced.confarea.html#svn.advanced.confarea.opts.config>
>
> --
> David Weintraub
> qazwart@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: On commit, svn server to change line ending to unix style for .sh files.
Posted by David Weintraub <qa...@gmail.com>.
Take a look at the "svn:eol-style" property. That allows you to
specify the line ending for a particular file.
If your goal is to make sure all files that end in *.sh must have this
property, you'll need to write a pre-commit hook script that allows
you to do this.
I do have such a script written in Perl, and will be happy to send it
to you if you'd like. It's part of a script that also verifies write
authorizations, protects tags from changes, and even allows you to
prevent people from creating files that contain invalid characters.
By the way, the pre-commit hook script will prohibit a commit if a
*.sh doesn't have the svn:eol-style property set to "LF", but won't
automatically add the svn:eol-style property to the file. You can't
really do this via server side. However, you can do this via the
autoproperties in your config file. I setup a company wide config
file, and after a few rejected commits, people are using it.
Properties: <http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.advanced.props>
Autoproperties Config:
<http://svnbook.red-bean.com/en/1.4/svn.advanced.confarea.html#svn.advanced.confarea.opts.config>
--
David Weintraub
qazwart@gmail.com
On Wed, Sep 3, 2008 at 3:31 PM, Fu-Tung Cheng <fu...@yahoo.com> wrote:
> Hi,
>
> I would like the server to store files with the extension .sh as unix style line endings even if those files are written on windows and committed from windows.
>
> When I checkout on windows the .sh files should be in unix format as I'd never want them in dos format.
>
> Is there a way to set this on the server side?
>
> Thank you,
>
> Fu-Tung
>
>
>
>
>
> ---------------------------------------------------------------------
> 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