From 7f1680477dba80a47fe05773384dc9bb7fc93321 Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Thu, 13 May 2021 19:25:31 +0100 Subject: [PATCH 1/7] Add a main csharp file BLD-5717 --- .gitignore | 388 ++++++++++++++++++++++++++++++++++++++++ src/CommitHooksMain.cs | 12 ++ src/commit-hooks.csproj | 13 ++ 3 files changed, 413 insertions(+) create mode 100644 .gitignore create mode 100644 src/CommitHooksMain.cs create mode 100644 src/commit-hooks.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72de34f --- /dev/null +++ b/.gitignore @@ -0,0 +1,388 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# 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/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Nuget personal access tokens and Credentials +nuget.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# 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 +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +.idea/ +*.sln.iml \ No newline at end of file diff --git a/src/CommitHooksMain.cs b/src/CommitHooksMain.cs new file mode 100644 index 0000000..c493aba --- /dev/null +++ b/src/CommitHooksMain.cs @@ -0,0 +1,12 @@ +using System; + +namespace Ccdc.CommitHooks +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/src/commit-hooks.csproj b/src/commit-hooks.csproj new file mode 100644 index 0000000..66b2112 --- /dev/null +++ b/src/commit-hooks.csproj @@ -0,0 +1,13 @@ + + + Exe + net5.0 + Ccdc.CommitHooks + true + true + true + false + link + false + + From 483ce3be4bb0e94922de529c78085306cbc726d0 Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Thu, 13 May 2021 19:26:18 +0100 Subject: [PATCH 2/7] Add an editorconfig to force some style BLD-5717 --- .editorconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..958660d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +# Set default charset +charset = utf-8 +trim_trailing_whitespace = true + +# 4 space indentation +[*.{py,cs,csproj,yml,xml}] +indent_style = space +indent_size = 4 From a66b5b1deb86b2ce6eebf23c41552dcdd7c0394e Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Thu, 13 May 2021 21:12:26 +0100 Subject: [PATCH 3/7] First attempt at building a binary package BLD-5717 --- .github/workflows/build_packages.yml | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/build_packages.yml diff --git a/.github/workflows/build_packages.yml b/.github/workflows/build_packages.yml new file mode 100644 index 0000000..1264e41 --- /dev/null +++ b/.github/workflows/build_packages.yml @@ -0,0 +1,78 @@ +name: Build release archives + +on: [push, pull_request] +# on: +# push: +# branches: [ $default-branch ] +# pull_request: +# branches: [ $default-branch ] + +jobs: + + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # Install the .NET Core workload + - name: Install .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 5.0.x + + # Execute all unit tests in the solution + - name: Execute unit tests + run: dotnet test + working-directory: src + + - name: Build windows x64 version + run: dotnet publish -c Release -r win10-x64 + working-directory: src + + - name: Build linux x64 version + run: dotnet publish -c Release -r linux-x64 + working-directory: src + + - name: Build macos x64 version + run: dotnet publish -c Release -r osx.10.15-x64 + working-directory: src + + - name: Add executables to windows x64 version package + uses: actions/upload-artifact@v2 + with: + name: win10-x64 + path: src/bin/Release/net5.0/win10-x64/publish/* + + - name: Add common scripts to windows x64 version package + uses: actions/upload-artifact@v2 + with: + name: win10-x64 + path: main/* + + - name: Add executables to linux x64 version package + uses: actions/upload-artifact@v2 + with: + name: linux-x64 + path: src/bin/Release/net5.0/linux-x64/publish/* + + - name: Add common scripts to linux x64 version package + uses: actions/upload-artifact@v2 + with: + name: linux-x64 + path: main/* + + - name: Add executables to macos x64 version package + uses: actions/upload-artifact@v2 + with: + name: macos-x64 + path: src/bin/Release/net5.0/osx.10.15-x64/publish/* + + - name: Add common scripts to macos x64 version package + uses: actions/upload-artifact@v2 + with: + name: macos-x64 + path: main/* From 77490b7a5c5033c4ba53232824c52bfeac7bc77b Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Fri, 14 May 2021 08:48:23 +0100 Subject: [PATCH 4/7] Add some structure BLD-5717 --- .github/workflows/build_packages.yml | 12 +-- commit-hooks.sln | 74 +++++++++++++++++++ .../Ccdc.CommitHooks.CommitHookExe.csproj} | 7 +- .../CommitHookExecutable.cs | 14 ++++ src/Ccdc.CommitHooks/Ccdc.CommitHooks.csproj | 7 ++ .../CommitHookCheckInterface.cs | 13 ++++ src/Ccdc.CommitHooks/CommonEntryPoint.cs | 26 +++++++ src/Ccdc.CommitHooks/SampleCommitHookCheck.cs | 17 +++++ src/CommitHooksMain.cs | 12 --- .../Ccdc.CommitHooks.UnitTestSuite.csproj | 26 +++++++ .../SampleUnitTest.cs | 19 +++++ 11 files changed, 206 insertions(+), 21 deletions(-) create mode 100644 commit-hooks.sln rename src/{commit-hooks.csproj => Ccdc.CommitHooks.CommitHookExe/Ccdc.CommitHooks.CommitHookExe.csproj} (74%) create mode 100644 src/Ccdc.CommitHooks.CommitHookExe/CommitHookExecutable.cs create mode 100644 src/Ccdc.CommitHooks/Ccdc.CommitHooks.csproj create mode 100644 src/Ccdc.CommitHooks/CommitHookCheckInterface.cs create mode 100644 src/Ccdc.CommitHooks/CommonEntryPoint.cs create mode 100644 src/Ccdc.CommitHooks/SampleCommitHookCheck.cs delete mode 100644 src/CommitHooksMain.cs create mode 100644 tests/UnitTests/Ccdc.CommitHooks.UnitTestSuite/Ccdc.CommitHooks.UnitTestSuite.csproj create mode 100644 tests/UnitTests/Ccdc.CommitHooks.UnitTestSuite/SampleUnitTest.cs diff --git a/.github/workflows/build_packages.yml b/.github/workflows/build_packages.yml index 1264e41..bd5df67 100644 --- a/.github/workflows/build_packages.yml +++ b/.github/workflows/build_packages.yml @@ -26,26 +26,22 @@ jobs: # Execute all unit tests in the solution - name: Execute unit tests - run: dotnet test - working-directory: src + run: dotnet test --runtime linux-x64 - name: Build windows x64 version run: dotnet publish -c Release -r win10-x64 - working-directory: src - name: Build linux x64 version run: dotnet publish -c Release -r linux-x64 - working-directory: src - name: Build macos x64 version run: dotnet publish -c Release -r osx.10.15-x64 - working-directory: src - name: Add executables to windows x64 version package uses: actions/upload-artifact@v2 with: name: win10-x64 - path: src/bin/Release/net5.0/win10-x64/publish/* + path: src/Ccdc.CommitHooks.CommitHookExe/bin/Release/net5.0/win10-x64/publish/* - name: Add common scripts to windows x64 version package uses: actions/upload-artifact@v2 @@ -57,7 +53,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: linux-x64 - path: src/bin/Release/net5.0/linux-x64/publish/* + path: src/Ccdc.CommitHooks.CommitHookExe/bin/Release/net5.0/linux-x64/publish/* - name: Add common scripts to linux x64 version package uses: actions/upload-artifact@v2 @@ -69,7 +65,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: macos-x64 - path: src/bin/Release/net5.0/osx.10.15-x64/publish/* + path: src/Ccdc.CommitHooks.CommitHookExe/bin/Release/net5.0/osx.10.15-x64/publish/* - name: Add common scripts to macos x64 version package uses: actions/upload-artifact@v2 diff --git a/commit-hooks.sln b/commit-hooks.sln new file mode 100644 index 0000000..0d4a049 --- /dev/null +++ b/commit-hooks.sln @@ -0,0 +1,74 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.6.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9D60917A-1B70-44D7-946E-309F3DE52524}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ccdc.CommitHooks", "src\Ccdc.CommitHooks\Ccdc.CommitHooks.csproj", "{E47A0487-A748-4A98-9624-C12F7766A380}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ccdc.CommitHooks.CommitHookExe", "src\Ccdc.CommitHooks.CommitHookExe\Ccdc.CommitHooks.CommitHookExe.csproj", "{FAD768A4-B484-4051-B4FE-49C3CF4417BB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{9CDB8A1B-7C6E-424D-8A55-D7FDB3FACFE7}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{B7E018F3-FD1D-44F4-986D-EC6D12AA0E2E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ccdc.CommitHooks.UnitTestSuite", "tests\UnitTests\Ccdc.CommitHooks.UnitTestSuite\Ccdc.CommitHooks.UnitTestSuite.csproj", "{A3C75A6A-A652-4275-B81A-0F7A07D529C5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E47A0487-A748-4A98-9624-C12F7766A380}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Debug|x64.ActiveCfg = Debug|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Debug|x64.Build.0 = Debug|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Debug|x86.ActiveCfg = Debug|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Debug|x86.Build.0 = Debug|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Release|Any CPU.Build.0 = Release|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Release|x64.ActiveCfg = Release|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Release|x64.Build.0 = Release|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Release|x86.ActiveCfg = Release|Any CPU + {E47A0487-A748-4A98-9624-C12F7766A380}.Release|x86.Build.0 = Release|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Debug|x64.ActiveCfg = Debug|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Debug|x64.Build.0 = Debug|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Debug|x86.ActiveCfg = Debug|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Debug|x86.Build.0 = Debug|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Release|Any CPU.Build.0 = Release|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Release|x64.ActiveCfg = Release|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Release|x64.Build.0 = Release|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Release|x86.ActiveCfg = Release|Any CPU + {FAD768A4-B484-4051-B4FE-49C3CF4417BB}.Release|x86.Build.0 = Release|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Debug|x64.ActiveCfg = Debug|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Debug|x64.Build.0 = Debug|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Debug|x86.ActiveCfg = Debug|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Debug|x86.Build.0 = Debug|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Release|Any CPU.Build.0 = Release|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Release|x64.ActiveCfg = Release|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Release|x64.Build.0 = Release|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Release|x86.ActiveCfg = Release|Any CPU + {A3C75A6A-A652-4275-B81A-0F7A07D529C5}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {E47A0487-A748-4A98-9624-C12F7766A380} = {9D60917A-1B70-44D7-946E-309F3DE52524} + {FAD768A4-B484-4051-B4FE-49C3CF4417BB} = {9D60917A-1B70-44D7-946E-309F3DE52524} + {B7E018F3-FD1D-44F4-986D-EC6D12AA0E2E} = {9CDB8A1B-7C6E-424D-8A55-D7FDB3FACFE7} + {A3C75A6A-A652-4275-B81A-0F7A07D529C5} = {B7E018F3-FD1D-44F4-986D-EC6D12AA0E2E} + EndGlobalSection +EndGlobal diff --git a/src/commit-hooks.csproj b/src/Ccdc.CommitHooks.CommitHookExe/Ccdc.CommitHooks.CommitHookExe.csproj similarity index 74% rename from src/commit-hooks.csproj rename to src/Ccdc.CommitHooks.CommitHookExe/Ccdc.CommitHooks.CommitHookExe.csproj index 66b2112..afc9529 100644 --- a/src/commit-hooks.csproj +++ b/src/Ccdc.CommitHooks.CommitHookExe/Ccdc.CommitHooks.CommitHookExe.csproj @@ -6,8 +6,13 @@ true true true - false + true link false + + + + + diff --git a/src/Ccdc.CommitHooks.CommitHookExe/CommitHookExecutable.cs b/src/Ccdc.CommitHooks.CommitHookExe/CommitHookExecutable.cs new file mode 100644 index 0000000..2cf9758 --- /dev/null +++ b/src/Ccdc.CommitHooks.CommitHookExe/CommitHookExecutable.cs @@ -0,0 +1,14 @@ +using System; + +namespace Ccdc.CommitHooks +{ + class CommitHookExecutable + { + static void Main(string[] args) + { + // Git commit hooks's return code is important + CommonEntryPoint ep = new CommonEntryPoint(args); + Environment.ExitCode = ep.main(); + } + } +} diff --git a/src/Ccdc.CommitHooks/Ccdc.CommitHooks.csproj b/src/Ccdc.CommitHooks/Ccdc.CommitHooks.csproj new file mode 100644 index 0000000..f208d30 --- /dev/null +++ b/src/Ccdc.CommitHooks/Ccdc.CommitHooks.csproj @@ -0,0 +1,7 @@ + + + + net5.0 + + + diff --git a/src/Ccdc.CommitHooks/CommitHookCheckInterface.cs b/src/Ccdc.CommitHooks/CommitHookCheckInterface.cs new file mode 100644 index 0000000..be4a611 --- /dev/null +++ b/src/Ccdc.CommitHooks/CommitHookCheckInterface.cs @@ -0,0 +1,13 @@ +using System; + +namespace Ccdc.CommitHooks +{ + interface CommitHookCheckInterface + { + // This runs on the client side + bool clientSideCheck(); + // This runs in github actions + bool githubSideCheck(); + } + +} diff --git a/src/Ccdc.CommitHooks/CommonEntryPoint.cs b/src/Ccdc.CommitHooks/CommonEntryPoint.cs new file mode 100644 index 0000000..08cb592 --- /dev/null +++ b/src/Ccdc.CommitHooks/CommonEntryPoint.cs @@ -0,0 +1,26 @@ +using System; + +namespace Ccdc.CommitHooks +{ + public class CommonEntryPoint + { + public CommonEntryPoint(string[] args) + { + // Read args: is this running under github actions or not? + + // Read args: what kind of commit hook this is: + // Full list is available at + // https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks + + // Instantiate CommitHookCheckInterface classes + } + + public int main() + { + // run CommitHookCheckInterface checks + // return 0 if everything is ok + // or 1 if something should be aborted + return 0; + } + } +} diff --git a/src/Ccdc.CommitHooks/SampleCommitHookCheck.cs b/src/Ccdc.CommitHooks/SampleCommitHookCheck.cs new file mode 100644 index 0000000..2422414 --- /dev/null +++ b/src/Ccdc.CommitHooks/SampleCommitHookCheck.cs @@ -0,0 +1,17 @@ +using System; + +namespace Ccdc.CommitHooks +{ + + public class SampleCommitHookCheck : CommitHookCheckInterface + { + public bool clientSideCheck() + { + return false; + } + public bool githubSideCheck() + { + return false; + } + } +} diff --git a/src/CommitHooksMain.cs b/src/CommitHooksMain.cs deleted file mode 100644 index c493aba..0000000 --- a/src/CommitHooksMain.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Ccdc.CommitHooks -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } -} diff --git a/tests/UnitTests/Ccdc.CommitHooks.UnitTestSuite/Ccdc.CommitHooks.UnitTestSuite.csproj b/tests/UnitTests/Ccdc.CommitHooks.UnitTestSuite/Ccdc.CommitHooks.UnitTestSuite.csproj new file mode 100644 index 0000000..49b84f2 --- /dev/null +++ b/tests/UnitTests/Ccdc.CommitHooks.UnitTestSuite/Ccdc.CommitHooks.UnitTestSuite.csproj @@ -0,0 +1,26 @@ + + + + net5.0 + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/tests/UnitTests/Ccdc.CommitHooks.UnitTestSuite/SampleUnitTest.cs b/tests/UnitTests/Ccdc.CommitHooks.UnitTestSuite/SampleUnitTest.cs new file mode 100644 index 0000000..ddfa492 --- /dev/null +++ b/tests/UnitTests/Ccdc.CommitHooks.UnitTestSuite/SampleUnitTest.cs @@ -0,0 +1,19 @@ +using System; +using Xunit; +using Ccdc.CommitHooks; + +namespace Ccdc.CommitHooks.UnitTestSuite +{ + // This is using xUnit.net + // https://xunit.net/docs/getting-started/netcore/cmdline + public class SampleUnitTest + { + [Fact] + public void Test1() + { + SampleCommitHookCheck c = new SampleCommitHookCheck(); + Assert.False(c.clientSideCheck()); + Assert.False(c.githubSideCheck()); + } + } +} From 2fbb5c2e46de3ee1e52d9b05b24fbb19e510098d Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Fri, 14 May 2021 09:02:18 +0100 Subject: [PATCH 5/7] Move python githooks module to main directory BLD-5717 --- main/githooks.py => githooks.py | 0 main.py | 1 - 2 files changed, 1 deletion(-) rename main/githooks.py => githooks.py (100%) diff --git a/main/githooks.py b/githooks.py similarity index 100% rename from main/githooks.py rename to githooks.py diff --git a/main.py b/main.py index eed0c27..f24c5b9 100755 --- a/main.py +++ b/main.py @@ -10,7 +10,6 @@ from pathlib import Path import sys -sys.path.insert(0, str(Path(__file__).resolve().parent / 'main')) import githooks if __name__ == '__main__': From 40558d948bbc7922b10795cf227addbe2d1002c4 Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Fri, 14 May 2021 09:03:23 +0100 Subject: [PATCH 6/7] Change client side hooks to use executable BLD-5717 --- main/commit-msg | 26 +++++++++++++++----------- main/pre-commit | 27 +++++++++++++++------------ main/pre-merge-commit | 27 +++++++++++++++------------ 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/main/commit-msg b/main/commit-msg index 0de1961..6532bed 100755 --- a/main/commit-msg +++ b/main/commit-msg @@ -1,12 +1,16 @@ -#!/usr/bin/env python3 -''' -A hook to check commit massage. +#!/usr/bin/env bash +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -This is currently used to decide if large file should be commited. - -''' - -import githooks - -if __name__ == '__main__': - exit(githooks.commit_msg_hook()) +case "$OSTYPE" in + darwin*) + $SCRIPT_DIR/Ccdc.CommitHooks.CommitHookExe --client-side --commit-msg + ;; + linux*) + $SCRIPT_DIR/Ccdc.CommitHooks.CommitHookExe --client-side --commit-msg + ;; + msys*) + $SCRIPT_DIR/Ccdc.CommitHooks.CommitHookExe.exe --client-side --commit-msg + ;; + *) + echo "unsupported OSTYPE: $OSTYPE" ;; +esac diff --git a/main/pre-commit b/main/pre-commit index 1e18904..36a2743 100755 --- a/main/pre-commit +++ b/main/pre-commit @@ -1,13 +1,16 @@ -#!/usr/bin/env python3 -''' -This is a git hook migrated from hg. +#!/usr/bin/env bash +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -Reference: -https://confluence.ccdc.cam.ac.uk/pages/viewpage.action?spaceKey=GIT&title=Hooks - -''' - -import githooks - -if __name__ == '__main__': - exit(githooks.commit_hook()) +case "$OSTYPE" in + darwin*) + $SCRIPT_DIR/Ccdc.CommitHooks.CommitHookExe --client-side --pre-commit + ;; + linux*) + $SCRIPT_DIR/Ccdc.CommitHooks.CommitHookExe --client-side --pre-commit + ;; + msys*) + $SCRIPT_DIR/Ccdc.CommitHooks.CommitHookExe.exe --client-side --pre-commit + ;; + *) + echo "unsupported OSTYPE: $OSTYPE" ;; +esac diff --git a/main/pre-merge-commit b/main/pre-merge-commit index 93c154b..d4e5801 100755 --- a/main/pre-merge-commit +++ b/main/pre-merge-commit @@ -1,13 +1,16 @@ -#!/usr/bin/env python3 -''' -This is a git hook migrated from hg. +#!/usr/bin/env bash +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -Reference: -https://confluence.ccdc.cam.ac.uk/pages/viewpage.action?spaceKey=GIT&title=Hooks - -''' - -import githooks - -if __name__ == '__main__': - exit(githooks.commit_hook(merge=True)) +case "$OSTYPE" in + darwin*) + $SCRIPT_DIR/Ccdc.CommitHooks.CommitHookExe --client-side --pre-merge-commit + ;; + linux*) + $SCRIPT_DIR/Ccdc.CommitHooks.CommitHookExe --client-side --pre-merge-commit + ;; + msys*) + $SCRIPT_DIR/Ccdc.CommitHooks.CommitHookExe.exe --client-side --pre-merge-commit + ;; + *) + echo "unsupported OSTYPE: $OSTYPE" ;; +esac From b4bf13c2f4325b67dff3d44f8ded926be4274717 Mon Sep 17 00:00:00 2001 From: Claudio Bantaloukas Date: Fri, 14 May 2021 09:09:48 +0100 Subject: [PATCH 7/7] Set PublishReadyToRun to false BLD-5717 --- .../Ccdc.CommitHooks.CommitHookExe.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ccdc.CommitHooks.CommitHookExe/Ccdc.CommitHooks.CommitHookExe.csproj b/src/Ccdc.CommitHooks.CommitHookExe/Ccdc.CommitHooks.CommitHookExe.csproj index afc9529..0275500 100644 --- a/src/Ccdc.CommitHooks.CommitHookExe/Ccdc.CommitHooks.CommitHookExe.csproj +++ b/src/Ccdc.CommitHooks.CommitHookExe/Ccdc.CommitHooks.CommitHookExe.csproj @@ -6,7 +6,7 @@ true true true - true + false link false