@ -59,6 +59,12 @@ var (
)
)
func runHookPreReceive ( c * cli . Context ) error {
func runHookPreReceive ( c * cli . Context ) error {
if os . Getenv ( models . EnvIsInternal ) == "true" {
return nil
}
setup ( "hooks/pre-receive.log" , false )
if len ( os . Getenv ( "SSH_ORIGINAL_COMMAND" ) ) == 0 {
if len ( os . Getenv ( "SSH_ORIGINAL_COMMAND" ) ) == 0 {
if setting . OnlyAllowPushIfGiteaEnvironmentSet {
if setting . OnlyAllowPushIfGiteaEnvironmentSet {
fail ( ` Rejecting changes as Gitea environment not set .
fail ( ` Rejecting changes as Gitea environment not set .
@ -69,8 +75,6 @@ Gitea or set your environment appropriately.`, "")
}
}
}
}
setup ( "hooks/pre-receive.log" , false )
// the environment setted on serv command
// the environment setted on serv command
isWiki := ( os . Getenv ( models . EnvRepoIsWiki ) == "true" )
isWiki := ( os . Getenv ( models . EnvRepoIsWiki ) == "true" )
username := os . Getenv ( models . EnvRepoUsername )
username := os . Getenv ( models . EnvRepoUsername )
@ -186,6 +190,12 @@ func runHookUpdate(c *cli.Context) error {
}
}
func runHookPostReceive ( c * cli . Context ) error {
func runHookPostReceive ( c * cli . Context ) error {
if os . Getenv ( models . EnvIsInternal ) == "true" {
return nil
}
setup ( "hooks/post-receive.log" , false )
if len ( os . Getenv ( "SSH_ORIGINAL_COMMAND" ) ) == 0 {
if len ( os . Getenv ( "SSH_ORIGINAL_COMMAND" ) ) == 0 {
if setting . OnlyAllowPushIfGiteaEnvironmentSet {
if setting . OnlyAllowPushIfGiteaEnvironmentSet {
fail ( ` Rejecting changes as Gitea environment not set .
fail ( ` Rejecting changes as Gitea environment not set .
@ -196,8 +206,6 @@ Gitea or set your environment appropriately.`, "")
}
}
}
}
setup ( "hooks/post-receive.log" , false )
// the environment setted on serv command
// the environment setted on serv command
repoUser := os . Getenv ( models . EnvRepoUsername )
repoUser := os . Getenv ( models . EnvRepoUsername )
isWiki := ( os . Getenv ( models . EnvRepoIsWiki ) == "true" )
isWiki := ( os . Getenv ( models . EnvRepoIsWiki ) == "true" )