fun prePushHookTemplate()

in bunch-cli/src/main/kotlin/org/jetbrains/bunches/hooks/HookCodeTemplate.kt [81:104]


fun prePushHookTemplate(bunchExecutablePath: File, oldHookPath: String, repoPath: File): String {
    return """
        #!/bin/bash

        $BUNCH_PRE_PUSH_HOOK_COMMENT_MARKER
        $BUNCH_EXECUTABLE_PATH_COMMENT_MARKER '${bunchExecutablePath.absolutePath}'
        $OLD_HOOK_PATH_COMMENT_MARKER $oldHookPath
        
        $oldHookPath
        exitCode=${'$'}?
        if [[ "${'$'}exitCode" -ne 0 ]]
        then
            exit ${'$'}exitCode
        fi
        
        remote="$1"
        url="$2"
        
        read ALL_SHAS
        
        '${bunchExecutablePath.absolutePath}' $HOOK_LAUNCH_COMMAND $BUNCH_PRE_PUSH_CHECK_COMMAND "${repoPath.absolutePath}" ${'$'}1 ${'$'}2 ${'$'}ALL_SHAS
        
        """.trimIndent()
}