diff --git a/.scripts/git_hooks/pre-commit b/.scripts/git_hooks/pre-commit new file mode 100644 index 000000000..7c7ac37c9 --- /dev/null +++ b/.scripts/git_hooks/pre-commit @@ -0,0 +1,10 @@ +#!/bin/sh +LC_ALL=C +# Select files to format +FILES=$(git diff --cached --name-only --diff-filter=ACM "*.cs" | sed 's| |\\ |g') +[ -z "$FILES" ] && exit 0 +# Format all selected files +echo "$FILES" | cat | xargs | sed -e 's/ /,/g' | xargs dotnet-format --include +# Add back the modified files to staging +echo "$FILES" | xargs git add +exit 0 \ No newline at end of file diff --git a/.scripts/init.js b/.scripts/init.js new file mode 100644 index 000000000..700b6ae55 --- /dev/null +++ b/.scripts/init.js @@ -0,0 +1,38 @@ +var fs = require('fs'); +var path = require('path'); +var exec = require('child_process').exec; +var hiddenHooksFolderPath = path.join(__dirname, '../.git/hooks'); +var hooksFolderPath = path.join(__dirname, 'git_hooks'); +var hooks = fs.readdirSync(hooksFolderPath); +function copyFile (source, target, cb) { + var cbCalled = false; + var rd = fs.createReadStream(source); + var wr = fs.createWriteStream(target); +function done(err) { + if (!cbCalled) { + cb(err); + cbCalled = true; + } + } +rd.on("error", done); + wr.on("error", done); + wr.on("close", done); + rd.pipe(wr); +} +hooks.forEach(function (hook) { + var hookSource = path.join(hooksFolderPath, hook); + var hookTarget = path.join(hiddenHooksFolderPath, hook); +copyFile(hookSource, hookTarget, function (err) { + if (!err) { + console.log(hook + ' added to your .git/hooks folder') + exec( + 'chmod +x ' + hookTarget, + function (error) { + if (!error) { + console.log(hookTarget + ' made executable'); + } + } + ); + } + }) +}); \ No newline at end of file diff --git a/Vonage.Common.Test/Vonage.Common.Test.csproj b/Vonage.Common.Test/Vonage.Common.Test.csproj index 5134c7834..5c007d1c0 100644 --- a/Vonage.Common.Test/Vonage.Common.Test.csproj +++ b/Vonage.Common.Test/Vonage.Common.Test.csproj @@ -63,5 +63,7 @@ Always - + + + diff --git a/Vonage.Common/Vonage.Common.csproj b/Vonage.Common/Vonage.Common.csproj index e59ad9711..7b7dd26ed 100644 --- a/Vonage.Common/Vonage.Common.csproj +++ b/Vonage.Common/Vonage.Common.csproj @@ -12,22 +12,25 @@ false false 6.8.0 - + false latest netstandard2.0 - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + + diff --git a/Vonage.Server.Test/Vonage.Server.Test.csproj b/Vonage.Server.Test/Vonage.Server.Test.csproj index d1589cc02..15a9b8037 100644 --- a/Vonage.Server.Test/Vonage.Server.Test.csproj +++ b/Vonage.Server.Test/Vonage.Server.Test.csproj @@ -161,5 +161,7 @@ PreserveNewest - + + + diff --git a/Vonage.Server/Vonage.Server.csproj b/Vonage.Server/Vonage.Server.csproj index 88e28e7a1..f98095d74 100644 --- a/Vonage.Server/Vonage.Server.csproj +++ b/Vonage.Server/Vonage.Server.csproj @@ -79,4 +79,7 @@ + + + \ No newline at end of file diff --git a/Vonage.Test.Unit/Vonage.Test.Unit.csproj b/Vonage.Test.Unit/Vonage.Test.Unit.csproj index 9752d65c5..485a38e04 100644 --- a/Vonage.Test.Unit/Vonage.Test.Unit.csproj +++ b/Vonage.Test.Unit/Vonage.Test.Unit.csproj @@ -14,14 +14,14 @@ - - - - - - - - + + + + + + + + all runtime; build; native; analyzers; buildtransitive @@ -33,12 +33,12 @@ - - + + - + @@ -408,7 +408,7 @@ PreserveNewest - + PreserveNewest @@ -676,10 +676,10 @@ PreserveNewest - - - - + + + + PreserveNewest @@ -867,5 +867,7 @@ PreserveNewest - + + + diff --git a/Vonage.sln b/Vonage.sln index 75922a59e..4013828cb 100644 --- a/Vonage.sln +++ b/Vonage.sln @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution CHANGELOG.md = CHANGELOG.md VIDEO_BETA_CHANGELOG.md = VIDEO_BETA_CHANGELOG.md .editorconfig = .editorconfig + .scripts\init.js = .scripts\init.js + .scripts\git_hooks\pre-commit = .scripts\git_hooks\pre-commit EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vonage", "Vonage\Vonage.csproj", "{41EF17C9-8D2E-4C7B-B2EE-3BD1A4CC1A1B}" diff --git a/Vonage/Vonage.csproj b/Vonage/Vonage.csproj index 29012ab5b..d94e58c26 100644 --- a/Vonage/Vonage.csproj +++ b/Vonage/Vonage.csproj @@ -90,4 +90,7 @@ + + + \ No newline at end of file