How can we improve SQL Source Control?

SQL Source Control Git Hook Support

Sql Source Control can be made better by adding support for git hooks in the Sql Management Studio Source Control interface.

Example: Create a pre-commit hook to stop outgoing commits if tsqlt tests do not pass.

Expected outcome: A commit that fails the pre-commit hook should not be created. This is the behavior of the git command line.

Current outcome: Sql Source Control does not respect the git hook and bypasses it allowing the commit to be made.

37 votes
Vote
Sign in
(thinking…)
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
Anonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

SQL Source Control 7 has now been released. In this version, SQL Source Control now uses the Git command line for all its Git interactions, which means it will support any Git hooks that have been configured.

You will need to ensure that you have Git.exe available in your system path – the easiest way to do this if you don’t already have Git installed is to download Git for windows (https://git-scm.com/download/win)

5 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...
  • Sam Blowes commented  ·   ·  Flag as inappropriate

    Hello and thank you for implementing this!

    However the commit message passed to the commit-msg hook is not the message that is defined by the user, instead it is a message generated by the tool.

    How can this be fixed?

  • Aaron Templeton commented  ·   ·  Flag as inappropriate

    Upon further research this appears to be a failing of the libgit2 API which you are using. Microsoft suffered the same failing with Visual Studio until they converted over to directly running the git.exe shell as of VS 2017. I would ask that you take a similar initiative. For now, we are catching the failings in a bare repository pre-receive hook which then forces the user to repair their local repository through either a "git commit --amend" or else an interactive rebase. This gets especially messy if they have already done any branch merging. Please see for reference: https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/4321705-enable-client-side-hooks-when-committing-code-to-a

  • Aaron Templeton commented  ·   ·  Flag as inappropriate

    I could almost swear that SQL Source Control used to honor the hook, or at least ran it even if it didn't honor the return code to abort. Now I'm finding it doesn't run the hook at all. I altered my hook to create a file, which is never created from Redgate, and had it append a constant to the message, which never gets appended, before exiting with a zero return code. So it isn't that SQL Source Control is not honoring the hook, it simply isn't even running that code any longer. Or perhaps ever, but I'm 99.99% sure it used to at least run the hook allowing content to be appended to the message. So it appears to have recently went from "broken" to "really broken".

  • Sam Blowes commented  ·   ·  Flag as inappropriate

    This is very important for audit purposes.

    Often a user should reference a ticket for each change.

Feedback and Knowledge Base