Skip to content

Commit

Permalink
My vcs-config change broke any place where we tried to marshal a repo to
Browse files Browse the repository at this point in the history
JSON. This is a temporary fix.
  • Loading branch information
kellegous committed Mar 11, 2015
1 parent a7a3f9f commit 69bc2fc
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/hound/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Repo struct {
Url string `json:"url"`
MsBetweenPolls int `json:"ms-between-poll"`
Vcs string `json:"vcs"`
VcsConfig json.RawMessage `json:"vcs-config"`
VcsConfig json.RawMessage `json:"-"`
UrlPattern *UrlPattern `json:"url-pattern"`
}

Expand All @@ -31,6 +31,30 @@ type Config struct {
Repos map[string]*Repo `json:"repos"`
}

// TODO(knorton): Hopefully this is a temporary measure while I straighten
// out what I broke. The issue is we cannot marshal Repos once I put the
// RawMessage in there.
func (r *Repo) UnmarshalJSON(b []byte) error {
var repo struct {
Url string `json:"url"`
MsBetweenPolls int `json:"ms-between-poll"`
Vcs string `json:"vcs"`
VcsConfig json.RawMessage `json:"vcs-config"`
UrlPattern *UrlPattern `json:"url-pattern"`
}

if err := json.Unmarshal(b, &repo); err != nil {
return err
}

r.Url = repo.Url
r.MsBetweenPolls = repo.MsBetweenPolls
r.Vcs = repo.Vcs
r.VcsConfig = repo.VcsConfig
r.UrlPattern = repo.UrlPattern
return nil
}

// Populate missing config values with default values.
func initRepo(r *Repo) {
if r.MsBetweenPolls == 0 {
Expand Down

0 comments on commit 69bc2fc

Please sign in to comment.