righteous 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjRhNTExNmZmY2FhMzZlZDc2ZmNlN2E2ZGU4ZmJiYTJhYWVmNmExNg==
5
+ data.tar.gz: !binary |-
6
+ YmU1MzRiM2U1ZDMwZDU2Yjg4M2I3YWZhNzI0ZGVhZmQwNzI4YTRmMw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YmE3MmNmMjc4YmNkYTk2OTU1ODE3NWU4ODMyZjRhMjg5YmNkOGM2NGUzMDhi
10
+ OTg3NGZiN2JiZDY3OTgyNDUwMjAwNGFiYmE2MTE4MTFmMzhiZTMxNjRkOWQ4
11
+ ZTdhN2Y1ODJmYjE3NDBlM2NhODhjOGVhZDAzYzQyODYwODNiYTI=
12
+ data.tar.gz: !binary |-
13
+ ZWQzNDQ5NTA4Yjc0ZjgxMDJmMmM3NjQyOTliYjViODFhNDE5NDg5MzkyMzVi
14
+ MDNmNzk5N2FhMmVhN2Q3ZTcwZWNiOTNkZWFiMTdmMWIxNjhhMTZiYzBhNzVl
15
+ MDhkZmZkY2NjMDNkYmQwNWQzNTRiNzJmOWY0OTFjNzZkMWNhNTA=
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ *.suo
3
+ [Bb]in
4
+ [Oo]bj
5
+ .idea
6
+ *.iml
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p448
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gem 'nokogiri'
data/Gemfile.lock ADDED
@@ -0,0 +1,12 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ mini_portile (0.5.1)
5
+ nokogiri (1.6.0)
6
+ mini_portile (~> 0.5.0)
7
+
8
+ PLATFORMS
9
+ ruby
10
+
11
+ DEPENDENCIES
12
+ nokogiri
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Righteous Git Hooks
2
+ Useful Git hooks for Visual Studio projects on Windows
3
+
4
+ _Note: This project is in its infancy, I need to wrap the tests in some kind of framework, add more hooks and tests, and build the installer. I'll probably make this available as a gem at some point as well..._
5
+
6
+ ## What?
7
+ These hooks are born out of frustration working with large complicated Visual Studio solutions, in large teams, where there are constant issues, such as:
8
+
9
+ * _Generated files (using .csproj `dependentupon` elements, e.g. CSS from SCSS or JavaScript from CoffeeScript) get added to the repository. [NOT IMPLEMENTED]_
10
+ * Linked files (using .csproj `link` elements) get added to the repository.
11
+ * _Content files get added to the project, but not to Git, resulting in working builds, but broken deployments. [NOT IMPLEMENTED]_
12
+ * _On Windows, incorrect Git config can result in multiple folders with names differing only by case, which causes other problems [NOT IMPLEMENTED]:_
13
+ - _Browsing the repository on GitHub becomes problematic._
14
+ - _Some users will not receive all the files when they check out a branch._
15
+ - _Git will in some cases track two separate files in the index, representing only one on disk._
16
+
17
+ Clearly, these are all problematic situations. Righteous Git Hooks aims to solve all of the above problems with code :)
18
+
19
+ ## Installation
20
+
21
+ Currently this is largely a manual process, I'll be aiming to improve this in the future. Any help with making the hooks more universal, easier to set up, or adding additional hooks, would be much appreciated.
22
+
23
+ ### Requirements:
24
+ 1. [Msys Git (i.e. Git for Windows) v1.8+](http://git-scm.com/download/win)
25
+ 2. [Ruby 1.9.3](http://rubyinstaller.org/downloads/) (not tested for other versions of Ruby, help with this appreciated)
26
+
27
+ ### Instructions:
28
+ 1. Open an admin command prompt
29
+ * Windows 8: Hit Windows Key -> type "cmd" -> right click "Command Prompt" -> Select "Run as administrator" from the footer menu.
30
+ 2. In the console:
31
+ * `C:\>gem install bundler`
32
+ * `C:\>cd righteous-git-hooks`
33
+ * `C:\>bundle install`
34
+ 3. Manually invoke righteous-pre-commit.sh from your repository's .git/hooks/pre-commit file.
35
+ * The plan is to automate this step with an installer ASAP.
@@ -0,0 +1,60 @@
1
+ require 'nokogiri'
2
+ require 'uri'
3
+ require_relative 'result'
4
+
5
+ module RighteousGitHooks
6
+
7
+ class ContentFilesChecker
8
+
9
+ def initialize(git_root, project_dir, csproj_filename)
10
+ @git_root = git_root
11
+ @project_dir = project_dir
12
+ @csproj_filename = csproj_filename
13
+ end
14
+
15
+ def adjudge!()
16
+
17
+ puts 'Checking content files are in your repository...'
18
+ csproj_path = File.join(@git_root, @project_dir, @csproj_filename)
19
+
20
+ return Result.error("Cannot find #{csproj_path}") unless File.exists? csproj_path
21
+
22
+ puts "Checking csproj: '#{csproj_path}'"
23
+ csproj = Nokogiri::XML(File.read(csproj_path))
24
+ sins = []
25
+
26
+ # Make list of all files from repo
27
+ # Make list of all files from csproj
28
+ # Make sure they're the same!
29
+
30
+ content_files = []
31
+ repo_files = []
32
+
33
+ Dir.chdir(@git_root) do
34
+ repo_files = `git ls-files`.split("\n")
35
+ end
36
+
37
+ csproj.css('ItemGroup > Content[Include]').each do |content|
38
+ # Issue: We are just checking individual projects, so we can't check
39
+ # content files in other projects where they are generated in those projects
40
+ # we need some way to include all csproj files in the search.
41
+ next if content['Include'][0..1] == '..'
42
+ next unless (content > "DependentUpon").empty?
43
+ test_path = File.expand_path(File.join(@project_dir, URI.unescape(content['Include']).gsub('\\', '/'))).gsub(@git_root + '/', '')
44
+ unless repo_files.include? test_path then
45
+ sins.push(test_path)
46
+ end
47
+ end
48
+
49
+ return Result.success("Congratulations, this is a righteous commit!") if sins.empty?
50
+
51
+ message = "\nYou have sinned! The following #{sins.length} files are csproj content files, but do not exist in your repo..."
52
+ sins.each do |sin|
53
+ message = message + "\n#{sin}"
54
+ end
55
+ message = message + "\nPlease add all #{sins.length} files or specify that they're DependentUpon in the csproj before committing."
56
+
57
+ return Result.error(message)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'linked-files-not-in-repo'
2
+ require_relative 'content-files-are-in-repo'
3
+ include RighteousGitHooks
4
+
5
+ if ARGV.length < 3 then
6
+ puts "You must supply at least 3 arguments: git_repo_dir, project_dir, csproj_filename"
7
+ exit 1
8
+ end
9
+
10
+ git_repo_dir = ARGV[0]
11
+ project_dir = ARGV[1]
12
+ csproj_filename = ARGV[2]
13
+ checker = ARGV[3]
14
+
15
+ checker = 'all' if checker.empty?
16
+
17
+ results = []
18
+
19
+ if checker == 'all' or checker == 'linked-files' then
20
+ the_righteous_linked_files_checker = LinkedFilesChecker.new(git_repo_dir, project_dir, csproj_filename)
21
+ results.push the_righteous_linked_files_checker.adjudge!
22
+ end
23
+ if checker == 'all' or checker == 'content-files' then
24
+ the_righteous_content_files_checker = ContentFilesChecker.new(git_repo_dir, project_dir, csproj_filename)
25
+ results.push the_righteous_content_files_checker.adjudge!
26
+ end
27
+
28
+ results.each { |r| puts r.message }
29
+
30
+ exit results.any? { |r| r.status_code > 0 } ? 1 : 0
@@ -0,0 +1,48 @@
1
+ require 'nokogiri'
2
+ require_relative 'result'
3
+
4
+ module RighteousGitHooks
5
+
6
+ class LinkedFilesChecker
7
+
8
+ def initialize(git_root, project_dir, csproj_filename)
9
+ @git_root = git_root
10
+ @project_dir = project_dir
11
+ @csproj_filename = csproj_filename
12
+ end
13
+
14
+ def adjudge!()
15
+
16
+ puts 'Checking linked files in your csproj are not in the repository...'
17
+ csproj_path = File.join(@git_root, @project_dir, @csproj_filename)
18
+
19
+ return Result.error("Cannot find #{csproj_path}") unless File.exists? csproj_path
20
+
21
+ puts "Checking csproj: '#{csproj_path}'"
22
+ csproj = Nokogiri::XML(File.read(csproj_path))
23
+ sins = []
24
+
25
+ Dir.chdir(@git_root) do
26
+ # CSS Selectors for maximum coolness (also XPath sucks)
27
+ csproj.css('ItemGroup > Content > Link').each do |link|
28
+ # Get the repo-relative path for each file with unix-style path separators
29
+ path = File.join(@project_dir, link.text.gsub('\\', '/'))
30
+ # Check the file is not staged in Git. An empty response means it's not staged
31
+ puts link.text
32
+ result = `git ls-files --stage #{path}`
33
+ sins.push(result) unless result.empty?
34
+ end
35
+ end
36
+
37
+ return Result.success("Congratulations, this is a righteous commit!") if sins.empty?
38
+
39
+ message = "\nYou have sinned! The following files are csproj links, but exist in your repo..."
40
+ sins.each do |sin|
41
+ message = message + "\n#{sin}"
42
+ end
43
+ message = message + "\nPlease delete them before committing. You may need to add them to .gitignore as well."
44
+
45
+ return Result.error(message)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,21 @@
1
+ module RighteousGitHooks
2
+ class Result
3
+ def initialize(message, status_code)
4
+ throw "You must supply both message and status_code" if message.to_s == "" or status_code.to_s == ""
5
+ throw "Status code must be either 0 or 1" unless [0,1].include? status_code
6
+ @message = message
7
+ @status_code = status_code
8
+ end
9
+
10
+ attr_reader :message
11
+ attr_reader :status_code
12
+
13
+ def self.success(message)
14
+ Result.new(message, 0)
15
+ end
16
+
17
+ def self.error(message)
18
+ Result.new(message, 1)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+ # This file causes all of the Git hooks to be invoked.
3
+ # Your pre-commit file (in .git/hooks) just needs to
4
+ # invoke this file, e.g.
5
+ #
6
+ # source ../git-hooks/justgiving-git-hooks.sh
7
+ echo 'Examining your staged commit for ultimate righteousness...'
8
+ ruby 'git-hooks/linked-files-not-in-repo.rb'
data/righteous.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "righteous"
3
+ s.version = "0.0.0"
4
+ s.platform = Gem::Platform::RUBY
5
+ s.author = "Samuel R. Salisbury"
6
+ s.email = "samsalisbury@gmail.com"
7
+ s.homepage = "http://github.com/samsalisbury/righteous-git-hooks"
8
+ s.summary = "ALPHA: Useful, easy-install Git hooks for Visual Studio projects and more."
9
+ s.description = "ALPHA: Managing the Git sins and foibles of a large development team on Git-unfriendly Windows was becoming a nightmare at work. I started writing hooks to mitigate some of the most common mistakes, and realised to get them adopted, they need to be really easy to set up. Thus, I'm starting this project to make headway into having useful git hooks anyone can use with minimal effort."
10
+
11
+ s.rubyforge_project = s.name
12
+
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+
15
+ # If you have runtime dependencies, add them here
16
+ # s.add_runtime_dependency "other", "~&gt; 1.2"
17
+
18
+ # If you have development dependencies, add them here
19
+ # s.add_development_dependency "another", "= 0.9"
20
+
21
+ # The list of files to be contained in the gem
22
+ s.files = `git ls-files`.split("\n")
23
+ # s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
24
+ # s.extensions = `git ls-files ext/extconf.rb`.split("\n")
25
+
26
+ s.require_path = 'lib'
27
+
28
+ # For C extensions
29
+ # s.extensions = "ext/extconf.rb"
30
+ end
@@ -0,0 +1,66 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
+ <PropertyGroup>
5
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
+ <ProjectGuid>{19DC5993-BDAA-4206-AA89-C5D99F2101CB}</ProjectGuid>
8
+ <OutputType>Exe</OutputType>
9
+ <AppDesignerFolder>Properties</AppDesignerFolder>
10
+ <RootNamespace>GitHooksTest</RootNamespace>
11
+ <AssemblyName>GitHooksTest</AssemblyName>
12
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13
+ <FileAlignment>512</FileAlignment>
14
+ </PropertyGroup>
15
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16
+ <PlatformTarget>AnyCPU</PlatformTarget>
17
+ <DebugSymbols>true</DebugSymbols>
18
+ <DebugType>full</DebugType>
19
+ <Optimize>false</Optimize>
20
+ <OutputPath>bin\Debug\</OutputPath>
21
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
22
+ <ErrorReport>prompt</ErrorReport>
23
+ <WarningLevel>4</WarningLevel>
24
+ </PropertyGroup>
25
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26
+ <PlatformTarget>AnyCPU</PlatformTarget>
27
+ <DebugType>pdbonly</DebugType>
28
+ <Optimize>true</Optimize>
29
+ <OutputPath>bin\Release\</OutputPath>
30
+ <DefineConstants>TRACE</DefineConstants>
31
+ <ErrorReport>prompt</ErrorReport>
32
+ <WarningLevel>4</WarningLevel>
33
+ </PropertyGroup>
34
+ <ItemGroup>
35
+ <Reference Include="System" />
36
+ <Reference Include="System.Core" />
37
+ <Reference Include="System.Xml.Linq" />
38
+ <Reference Include="System.Data.DataSetExtensions" />
39
+ <Reference Include="Microsoft.CSharp" />
40
+ <Reference Include="System.Data" />
41
+ <Reference Include="System.Xml" />
42
+ </ItemGroup>
43
+ <ItemGroup>
44
+ <Compile Include="Program.cs" />
45
+ <Compile Include="Properties\AssemblyInfo.cs" />
46
+ </ItemGroup>
47
+ <ItemGroup>
48
+ <Content Include="GeneratedFile.txt">
49
+ <DependentUpon>SourceFile.txt</DependentUpon>
50
+ </Content>
51
+ <Content Include="SourceFile.txt" />
52
+ </ItemGroup>
53
+ <ItemGroup>
54
+ <None Include="..\GitHooksTest.Lib\LinkedFile.config">
55
+ <Link>LinkedFile.config</Link>
56
+ </None>
57
+ </ItemGroup>
58
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
59
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
60
+ Other similar extension points exist, see Microsoft.Common.targets.
61
+ <Target Name="BeforeBuild">
62
+ </Target>
63
+ <Target Name="AfterBuild">
64
+ </Target>
65
+ -->
66
+ </Project>
@@ -0,0 +1,15 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Linq;
4
+ using System.Text;
5
+ using System.Threading.Tasks;
6
+
7
+ namespace GitHooksTest
8
+ {
9
+ class Program
10
+ {
11
+ static void Main(string[] args)
12
+ {
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,36 @@
1
+ using System.Reflection;
2
+ using System.Runtime.CompilerServices;
3
+ using System.Runtime.InteropServices;
4
+
5
+ // General Information about an assembly is controlled through the following
6
+ // set of attributes. Change these attribute values to modify the information
7
+ // associated with an assembly.
8
+ [assembly: AssemblyTitle("GitHooksTest")]
9
+ [assembly: AssemblyDescription("")]
10
+ [assembly: AssemblyConfiguration("")]
11
+ [assembly: AssemblyCompany("")]
12
+ [assembly: AssemblyProduct("GitHooksTest")]
13
+ [assembly: AssemblyCopyright("Copyright © 2013")]
14
+ [assembly: AssemblyTrademark("")]
15
+ [assembly: AssemblyCulture("")]
16
+
17
+ // Setting ComVisible to false makes the types in this assembly not visible
18
+ // to COM components. If you need to access a type in this assembly from
19
+ // COM, set the ComVisible attribute to true on that type.
20
+ [assembly: ComVisible(false)]
21
+
22
+ // The following GUID is for the ID of the typelib if this project is exposed to COM
23
+ [assembly: Guid("6f443b5e-fbab-46fa-b81b-f678a3b24417")]
24
+
25
+ // Version information for an assembly consists of the following four values:
26
+ //
27
+ // Major Version
28
+ // Minor Version
29
+ // Build Number
30
+ // Revision
31
+ //
32
+ // You can specify all the values or you can default the Build and Revision Numbers
33
+ // by using the '*' as shown below:
34
+ // [assembly: AssemblyVersion("1.0.*")]
35
+ [assembly: AssemblyVersion("1.0.0.0")]
36
+ [assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,12 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Linq;
4
+ using System.Text;
5
+ using System.Threading.Tasks;
6
+
7
+ namespace GitHooksTest.Lib
8
+ {
9
+ public class Class1
10
+ {
11
+ }
12
+ }
@@ -0,0 +1,56 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4
+ <PropertyGroup>
5
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
+ <ProjectGuid>{7A4731D0-E340-4447-A290-FFE555352181}</ProjectGuid>
8
+ <OutputType>Library</OutputType>
9
+ <AppDesignerFolder>Properties</AppDesignerFolder>
10
+ <RootNamespace>GitHooksTest.Lib</RootNamespace>
11
+ <AssemblyName>GitHooksTest.Lib</AssemblyName>
12
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13
+ <FileAlignment>512</FileAlignment>
14
+ </PropertyGroup>
15
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16
+ <DebugSymbols>true</DebugSymbols>
17
+ <DebugType>full</DebugType>
18
+ <Optimize>false</Optimize>
19
+ <OutputPath>bin\Debug\</OutputPath>
20
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
21
+ <ErrorReport>prompt</ErrorReport>
22
+ <WarningLevel>4</WarningLevel>
23
+ </PropertyGroup>
24
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25
+ <DebugType>pdbonly</DebugType>
26
+ <Optimize>true</Optimize>
27
+ <OutputPath>bin\Release\</OutputPath>
28
+ <DefineConstants>TRACE</DefineConstants>
29
+ <ErrorReport>prompt</ErrorReport>
30
+ <WarningLevel>4</WarningLevel>
31
+ </PropertyGroup>
32
+ <ItemGroup>
33
+ <Reference Include="System" />
34
+ <Reference Include="System.Core" />
35
+ <Reference Include="System.Xml.Linq" />
36
+ <Reference Include="System.Data.DataSetExtensions" />
37
+ <Reference Include="Microsoft.CSharp" />
38
+ <Reference Include="System.Data" />
39
+ <Reference Include="System.Xml" />
40
+ </ItemGroup>
41
+ <ItemGroup>
42
+ <Compile Include="Class1.cs" />
43
+ <Compile Include="Properties\AssemblyInfo.cs" />
44
+ </ItemGroup>
45
+ <ItemGroup>
46
+ <None Include="LinkedFile.config" />
47
+ </ItemGroup>
48
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
49
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
50
+ Other similar extension points exist, see Microsoft.Common.targets.
51
+ <Target Name="BeforeBuild">
52
+ </Target>
53
+ <Target Name="AfterBuild">
54
+ </Target>
55
+ -->
56
+ </Project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <configuration>
3
+ <startup>
4
+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5
+ </startup>
6
+ </configuration>
@@ -0,0 +1,36 @@
1
+ using System.Reflection;
2
+ using System.Runtime.CompilerServices;
3
+ using System.Runtime.InteropServices;
4
+
5
+ // General Information about an assembly is controlled through the following
6
+ // set of attributes. Change these attribute values to modify the information
7
+ // associated with an assembly.
8
+ [assembly: AssemblyTitle("GitHooksTest.Lib")]
9
+ [assembly: AssemblyDescription("")]
10
+ [assembly: AssemblyConfiguration("")]
11
+ [assembly: AssemblyCompany("")]
12
+ [assembly: AssemblyProduct("GitHooksTest.Lib")]
13
+ [assembly: AssemblyCopyright("Copyright © 2013")]
14
+ [assembly: AssemblyTrademark("")]
15
+ [assembly: AssemblyCulture("")]
16
+
17
+ // Setting ComVisible to false makes the types in this assembly not visible
18
+ // to COM components. If you need to access a type in this assembly from
19
+ // COM, set the ComVisible attribute to true on that type.
20
+ [assembly: ComVisible(false)]
21
+
22
+ // The following GUID is for the ID of the typelib if this project is exposed to COM
23
+ [assembly: Guid("93086b3e-b0af-4330-b339-598ebe915b92")]
24
+
25
+ // Version information for an assembly consists of the following four values:
26
+ //
27
+ // Major Version
28
+ // Minor Version
29
+ // Build Number
30
+ // Revision
31
+ //
32
+ // You can specify all the values or you can default the Build and Revision Numbers
33
+ // by using the '*' as shown below:
34
+ // [assembly: AssemblyVersion("1.0.*")]
35
+ [assembly: AssemblyVersion("1.0.0.0")]
36
+ [assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,26 @@
1
+ 
2
+ Microsoft Visual Studio Solution File, Format Version 12.00
3
+ # Visual Studio 2012
4
+ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHooksTest", "GitHooksTest\GitHooksTest.csproj", "{19DC5993-BDAA-4206-AA89-C5D99F2101CB}"
5
+ EndProject
6
+ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHooksTest.Lib", "GitHooksTest.Lib\GitHooksTest.Lib.csproj", "{7A4731D0-E340-4447-A290-FFE555352181}"
7
+ EndProject
8
+ Global
9
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+ Debug|Any CPU = Debug|Any CPU
11
+ Release|Any CPU = Release|Any CPU
12
+ EndGlobalSection
13
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
14
+ {19DC5993-BDAA-4206-AA89-C5D99F2101CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15
+ {19DC5993-BDAA-4206-AA89-C5D99F2101CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
16
+ {19DC5993-BDAA-4206-AA89-C5D99F2101CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
17
+ {19DC5993-BDAA-4206-AA89-C5D99F2101CB}.Release|Any CPU.Build.0 = Release|Any CPU
18
+ {7A4731D0-E340-4447-A290-FFE555352181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19
+ {7A4731D0-E340-4447-A290-FFE555352181}.Debug|Any CPU.Build.0 = Debug|Any CPU
20
+ {7A4731D0-E340-4447-A290-FFE555352181}.Release|Any CPU.ActiveCfg = Release|Any CPU
21
+ {7A4731D0-E340-4447-A290-FFE555352181}.Release|Any CPU.Build.0 = Release|Any CPU
22
+ EndGlobalSection
23
+ GlobalSection(SolutionProperties) = preSolution
24
+ HideSolutionNode = FALSE
25
+ EndGlobalSection
26
+ EndGlobal
@@ -0,0 +1,70 @@
1
+ # 1. Copy the solution and make a new git repo
2
+ # 2. Init a new git repo, and commit status quo
3
+ # 3. Get the commit sha, then poke around in the repo and try to commit, running the tests...
4
+
5
+ require 'securerandom'
6
+
7
+ def generate_dirname()
8
+ "~/.righteous-git-hooks-temp-test-repo-" + SecureRandom.uuid[0..7]
9
+ end
10
+
11
+ temp_dir = File.expand_path(generate_dirname())
12
+ if File.directory? temp_dir
13
+ puts "Directory #{temp_dir} already exists, can't continue."
14
+ exit 1
15
+ end
16
+
17
+ `mkdir #{temp_dir}`
18
+
19
+ tests_root = File.expand_path(File.dirname(__FILE__))
20
+
21
+ master_data_dir = File.join(tests_root, 'GitHooksTestSolution')
22
+ hook_script = File.join(tests_root, "../lib/hooks/go_go_righteous_git_hooks.rb")
23
+
24
+ a_test_failed = 0
25
+
26
+ # Setup
27
+ Dir.chdir(File.expand_path(temp_dir)) do
28
+ `cp -r #{master_data_dir}/* #{temp_dir}`
29
+ `git init`
30
+ `git add -A`
31
+ `git commit -m 'Test commit.'`
32
+ end
33
+
34
+ # When all content files exist, message should be positive, exit code zero
35
+ Dir.chdir(File.expand_path(temp_dir)) do
36
+ # Arrange - nothing to do this time...
37
+
38
+ # Act
39
+ result = `ruby #{hook_script} $PWD GitHooksTest GitHooksTest.csproj content-files`
40
+ # Assert
41
+ if result.split("\n").last == 'Congratulations, this is a righteous commit!' then
42
+ puts 'Test passed!'
43
+ else
44
+ puts 'Test failed.'
45
+ a_test_failed += 1
46
+ end
47
+ end
48
+
49
+ # When a content file is missing, exit code 1, negative message
50
+ Dir.chdir(File.expand_path(temp_dir)) do
51
+ # Arrange - delete a content file and try to commit
52
+ puts "rm #{temp_dir}/GitHooksTest/SourceFile.txt"
53
+ `rm #{temp_dir}/GitHooksTest/SourceFile.txt`
54
+ `git add -A`
55
+ # Act
56
+ result = `ruby #{hook_script} $PWD GitHooksTest GitHooksTest.csproj content-files`
57
+ # Assert
58
+ if result.split("\n").last != 'Congratulations, this is a righteous commit!' then
59
+ puts 'Test passed!'
60
+ else
61
+ puts 'Test failed.'
62
+ puts result
63
+ a_test_failed += 1
64
+ end
65
+ end
66
+
67
+ # clean up directory
68
+ `rm -rf #{temp_dir}`
69
+
70
+ exit a_test_failed
@@ -0,0 +1,46 @@
1
+ # 1. Copy the solution and make a new git repo
2
+ # 2. Init a new git repo, and commit status quo
3
+ # 3. Get the commit sha, then poke around in the repo and try to commit, running the tests...
4
+
5
+ require 'securerandom'
6
+
7
+ def generate_dirname()
8
+ "~/.righteous-git-hooks-temp-test-repo-" + SecureRandom.uuid[0..7]
9
+ end
10
+
11
+ temp_dir = File.expand_path(generate_dirname())
12
+ if File.directory? temp_dir
13
+ puts "Directory #{temp_dir} already exists, can't continue."
14
+ exit 1
15
+ end
16
+
17
+ `mkdir #{temp_dir}`
18
+
19
+ tests_root = File.expand_path(File.dirname(__FILE__))
20
+
21
+ master_data_dir = File.join(tests_root, 'GitHooksTestSolution')
22
+ hook_script = File.join(tests_root, "../lib/hooks/go_go_righteous_git_hooks.rb")
23
+
24
+ a_test_failed = 0
25
+
26
+ Dir.chdir(File.expand_path(temp_dir)) do
27
+ # Arrange - copy files, create test repo and commit
28
+ `cp -r #{master_data_dir}/* #{temp_dir}`
29
+ `git init`
30
+ `git add -A`
31
+ `git commit -m 'Test commit.'`
32
+ # Act
33
+ result = `ruby #{hook_script} $PWD GitHooksTest GitHooksTest.csproj linked-files`
34
+ # Assert
35
+ if result.split("\n").last == 'Congratulations, this is a righteous commit!' then
36
+ puts 'Test passed!'
37
+ else
38
+ puts 'Test failed.'
39
+ a_test_failed += 1
40
+ end
41
+ end
42
+
43
+ # clean up directory
44
+ `rm -rf #{temp_dir}`
45
+
46
+ exit a_test_failed
data/test/runtests.sh ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ test_dir=$(dirname $0)
3
+ ruby "$test_dir/content-files-are-in-repo-tests.rb"
4
+ ruby "$test_dir/linked-files-not-in-repo-tests.rb"
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: righteous
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Samuel R. Salisbury
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ! 'ALPHA: Managing the Git sins and foibles of a large development team
14
+ on Git-unfriendly Windows was becoming a nightmare at work. I started writing hooks
15
+ to mitigate some of the most common mistakes, and realised to get them adopted,
16
+ they need to be really easy to set up. Thus, I''m starting this project to make
17
+ headway into having useful git hooks anyone can use with minimal effort.'
18
+ email: samsalisbury@gmail.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - .gitignore
24
+ - .ruby-version
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - README.md
28
+ - lib/hooks/content-files-are-in-repo.rb
29
+ - lib/hooks/go_go_righteous_git_hooks.rb
30
+ - lib/hooks/linked-files-not-in-repo.rb
31
+ - lib/hooks/result.rb
32
+ - lib/hooks/righteous-pre-commit.sh
33
+ - righteous.gemspec
34
+ - test/GitHooksTestSolution/GitHooksTest.Lib/Class1.cs
35
+ - test/GitHooksTestSolution/GitHooksTest.Lib/GitHooksTest.Lib.csproj
36
+ - test/GitHooksTestSolution/GitHooksTest.Lib/LinkedFile.config
37
+ - test/GitHooksTestSolution/GitHooksTest.Lib/Properties/AssemblyInfo.cs
38
+ - test/GitHooksTestSolution/GitHooksTest.sln
39
+ - test/GitHooksTestSolution/GitHooksTest/GeneratedFile.txt
40
+ - test/GitHooksTestSolution/GitHooksTest/GitHooksTest.csproj
41
+ - test/GitHooksTestSolution/GitHooksTest/Program.cs
42
+ - test/GitHooksTestSolution/GitHooksTest/Properties/AssemblyInfo.cs
43
+ - test/GitHooksTestSolution/GitHooksTest/SourceFile.txt
44
+ - test/content-files-are-in-repo-tests.rb
45
+ - test/linked-files-not-in-repo-tests.rb
46
+ - test/runtests.sh
47
+ homepage: http://github.com/samsalisbury/righteous-git-hooks
48
+ licenses: []
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: 1.3.6
64
+ requirements: []
65
+ rubyforge_project: righteous
66
+ rubygems_version: 2.0.6
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: ! 'ALPHA: Useful, easy-install Git hooks for Visual Studio projects and more.'
70
+ test_files: []