-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (50 loc) · 1.09 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"flag"
"time"
)
type PullRequest struct {
URL string
Title string
Author string
CreatedTime time.Time
}
type Repository interface {
PullRequests() []*PullRequest
}
type Reminder interface {
Remind([]*PullRequest)
}
func newRepository(c *Config) Repository {
github := NewGitHubRepository()
for _, url := range c.GitHub.Repositories {
github.AddRepo(url)
}
if c.GitHub.URL != "" {
github.SetURL(c.GitHub.URL, c.GitHub.Insecure)
}
if c.GitHub.Filter.MinAge.Duration > 0 {
github.SetMinAge(c.GitHub.Filter.MinAge.Duration)
}
return github
}
func newReminder(c *Config) Reminder {
hipchat := NewHipChatReminder(c.HipChat.Room)
if c.HipChat.Token != "" {
hipchat.SetToken(c.HipChat.Token)
}
return hipchat
}
func main() {
var configPath string
flag.StringVar(&configPath, "config", "git-remind-config.json", "Config file path")
flag.Parse()
if configPath == "" {
flag.Usage()
return
}
config := LoadConfig(configPath)
repository := newRepository(config)
reminder := newReminder(config)
reminder.Remind(repository.PullRequests())
}