1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.SvnHooks
.CastleProject
19 using System
.Collections
;
21 using Castle
.SvnHooks
;
23 /// This hook controls that a file has its svn:eol-style
26 public class PreCommitEolStyle
: IPreCommit
28 public PreCommitEolStyle(String extensions
) : this(extensions
.Split(' ', '|'))
31 public PreCommitEolStyle(String
[] extensionStrings
)
33 this.extensions
= extensionStrings
;
37 #region IPreCommit Members
39 public Error
[] PreCommit(RepositoryFile file
)
41 // Check files that have the proper extension
42 // but skip the files that are deleted
43 if (file
.ContentsStatus
== RepositoryStatus
.Deleted
||
44 Array
.IndexOf(extensions
, file
.Extension
) == -1)
46 return Error
.NoErrors
;
49 ArrayList errors
= new ArrayList();
51 String
[] props
= file
.GetProperty("svn:eol-style");
53 if (props
== null || props
.Length
== 0 || props
[0].ToLower() != "native")
55 return new Error
[]{new Error(file, "This file must have svn:eol-style set to native")}
;
58 return Error
.NoErrors
;
62 Error
[] Castle
.SvnHooks
.IPreCommit
.PreCommit(RepositoryDirectory directory
)
64 // Directories dont have any svn:eol-style properties
71 private String
[] extensions
;