Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / Experiments / SubversionHooks / CastleProjectHooks / PreCommitEolStyle.cs
blob129242dfcff010aa8cbb3b738e24009318e0677f
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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
17 using System;
18 using System.IO;
19 using System.Collections;
21 using Castle.SvnHooks;
22 /// <summary>
23 /// This hook controls that a file has its svn:eol-style
24 /// set to native.
25 /// </summary>
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
65 return null;
69 #endregion
71 private String[] extensions;