Skip to content

Commit

Permalink
use a new hooks dir struct (go-gitea#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Feb 24, 2017
1 parent 2187360 commit 0c5c193
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"

"github.com/Unknwon/com"
Expand All @@ -17,7 +18,7 @@ import (
// hookNames is a list of Git server hooks' name that are supported.
var hookNames = []string{
"pre-receive",
// "update",
"update",
"post-receive",
}

Expand Down Expand Up @@ -52,17 +53,18 @@ func GetHook(repoPath, name string) (*Hook, error) {
}
h := &Hook{
name: name,
path: path.Join(repoPath, "hooks", name),
path: path.Join(repoPath, "hooks", name+".d", name),
}
samplePath := filepath.Join(repoPath, "hooks", name+".sample")
if isFile(h.path) {
data, err := ioutil.ReadFile(h.path)
if err != nil {
return nil, err
}
h.IsActive = true
h.Content = string(data)
} else if isFile(h.path + ".sample") {
data, err := ioutil.ReadFile(h.path + ".sample")
} else if isFile(samplePath) {
data, err := ioutil.ReadFile(samplePath)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 0c5c193

Please sign in to comment.