Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
First commit
  • Loading branch information
senzacionale committed Dec 29, 2015
0 parents commit 86e63b8
Show file tree
Hide file tree
Showing 8 changed files with 406 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
167 changes: 167 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#################
## Eclipse
#################

*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath


#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Rr]elease/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
.builds
*.dotCover

## TODO: If you have NuGet Package Restore enabled, uncomment this
#packages/

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf

# Visual Studio profiler
*.psess
*.vsp

# ReSharper is a .NET coding add-in
_ReSharper*

# Installshield output folder
[Ee]xpress

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish

# Others
[Bb]in
[Oo]bj
sql
TestResults
*.Cache
ClientBin
stylecop.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML



############
## Windows
############

# Windows image file caches
Thumbs.db

# Folder config file
Desktop.ini

#SVN
*.svn
.svn


#############
## Python
#############

*.py[co]

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg

# Mac crap
.DS_Store
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#VisualSVNHookHandler code repo##post-commit-hookCode for a custom post-commit hook executable that can be used with VisualSVN server. There is a project that contains C# versions of the code.Build the project and copy the .exe file from the bin/debug folder in your project to the bin folder in your VisualSVN server installation folder, which in my case was C:\Program Files\VisualSVN Server\bin. Then, open up VisualSVN server and right click on the repository that you want to add the post-commit hook to and click properties.Open the hooks tab and double click on Post-commit hook. It will open a window that you need to paste the following code into. All it does is tell VisualSVN to run the .exe when a commit happens and passes in the required arguments:```csharp"%VISUALSVN_SERVER%bin<name_of_your_built_exe>.exe" "%1" %2 "[email protected],[email protected]"``` where "[email protected],[email protected]" are comma separated recipients list.
Expand Down
22 changes: 22 additions & 0 deletions VisualSVNHookHandler/VisualSVNHookHandler.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualSVNHookHandler", "VisualSVNHookHandler\VisualSVNHookHandler.csproj", "{2422C5FE-8A64-4C9C-BA45-2518258A257E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2422C5FE-8A64-4C9C-BA45-2518258A257E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2422C5FE-8A64-4C9C-BA45-2518258A257E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2422C5FE-8A64-4C9C-BA45-2518258A257E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2422C5FE-8A64-4C9C-BA45-2518258A257E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions VisualSVNHookHandler/VisualSVNHookHandler/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
94 changes: 94 additions & 0 deletions VisualSVNHookHandler/VisualSVNHookHandler/PostCommit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net.Mail;
using System.Text;

namespace VisualSVNHookHandler
{
public static class PostCommit
{
private static readonly string Svnpath = Environment.GetEnvironmentVariable("VISUALSVN_SERVER");
private static int Main(string[] args)
{
//Check if revision number and revision path have been supplied.
if (args.Length < 3)
{
Console.Error.WriteLine("Invalid arguments sent - <REPOSITORY> <REV> <SEND_TO> required");
return 1;
}

//Check if VisualSVN is installed.
if (string.IsNullOrEmpty(Svnpath))
{
Console.Error.WriteLine("VISUALSVN_SERVER environment variable does not exist. VisualSVN installed?");
return 1;
}

//Get the required information using SVNLook.
string author = SvnLook("author", args);
string message = SvnLook("log", args);
string changed = SvnLook("changed", args);

//Get the branch from the first change in the list.
string[] changeList = changed.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
string changeFirst = changeList[0].Remove(0, 4);
int changeFirstSlash = changeFirst.IndexOf("/", StringComparison.Ordinal);
string repoBranch = changeFirst.Substring(0, changeFirstSlash);

//Get the name of the repository from the first argument, which is the repo path.
string repoName = args[0].ToString().Substring(args[0].LastIndexOf(@"\", StringComparison.Ordinal) + 1);

//Get the email template and fill it in. This template can be anywhere, and can be a .HTML file
//for more control over the structure.
const string emailTemplatePath = @"C:\hooks\PostCommit.txt";
string emailTemplate = string.Format(File.ReadAllText(emailTemplatePath), author, message, changed);

//Construct the email that will be sent. You can use the .IsBodyHtml property if you are
//using an HTML template.
string subject = string.Format("Commit number {0} for {1}", args[1], repoName);
MailMessage mm = new MailMessage("<from email>", args[2]);
mm.Body = emailTemplate;
mm.Subject = subject;

//Define your mail client. I am using Gmail here as the SMTP server, but you could
//use IIS or Amazon SES or whatever you want.
SmtpClient mailClient = new SmtpClient("smtp.gmail.com");
mailClient.Port = 587;
mailClient.Credentials = new System.Net.NetworkCredential("<gmail username>", "<gmail password>");
mailClient.EnableSsl = false;

mailClient.Send(mm);

return 0;
}

/// <summary>
/// Runs a command on svnlook.exe to get information
/// about a particular repo and revision.
/// </summary>
/// <param name="command">The svnlook command e.g. log, author, message.</param>
/// <param name="args">The arguments passed in to this exe (repo name and rev number).</param>
/// <returns>The output of svnlook.exe</returns>
private static string SvnLook(string command, string[] args)
{
StringBuilder output = new StringBuilder();
Process procMessage = new Process();

//Start svnlook.exe in a process and pass it the required command-line args.
procMessage.StartInfo = new ProcessStartInfo(Svnpath + @"bin\svnlook.exe", String.Format(@"{0} ""{1}"" -r ""{2}""", command, args[0], args[1]));
procMessage.StartInfo.RedirectStandardOutput = true;
procMessage.StartInfo.UseShellExecute = false;
procMessage.Start();

//While reading the output of svnlook, append it to the stringbuilder then
//return the output.
while (!procMessage.HasExited)
{
output.Append(procMessage.StandardOutput.ReadToEnd());
}

return output.ToString();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("VisualSVNHookHandler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VisualSVNHookHandler")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b9a99c57-8007-4297-ae4f-042ef800ed0e")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 86e63b8

Please sign in to comment.