diff --git a/bots-common/obs_utils.go b/bots-common/obs_utils.go index 28fd157..36bf901 100644 --- a/bots-common/obs_utils.go +++ b/bots-common/obs_utils.go @@ -61,9 +61,9 @@ type RepositoryPathMeta struct { type RepositoryMeta struct { Name string `xml:"name,attr"` - BuildTrigger string `xml:"rebuild,attr"` - BlockMode string `xml:"block"` - LinkedBuild string `xml:"linkedbuild"` + BuildTrigger string `xml:"rebuild,attr,omitempty"` + BlockMode string `xml:"block,attr,omitempty"` + LinkedBuild string `xml:"linkedbuild,attr,omitempty"` Archs []string `xml:"arch"` Paths []RepositoryPathMeta `xml:"path"` } @@ -76,8 +76,8 @@ type ProjectMeta struct { XMLName xml.Name `xml:"project"` Name string `xml:"name,attr"` Title string `xml:"title"` - Description string `xml:"description"` - Url string `xml:"url"` + Description string `xml:"description,omitempty"` + Url string `xml:"url,omitempty"` ScmSync string `xml:"scmsync"` Repositories []RepositoryMeta `xml:"repository"` diff --git a/obs-staging-bot/main.go b/obs-staging-bot/main.go index c7aec77..58bc184 100644 --- a/obs-staging-bot/main.go +++ b/obs-staging-bot/main.go @@ -551,17 +551,30 @@ func pollWorkNotifications(giteaHost string) { if data != nil { for _, notification := range data { - switch notification.Subject.Type { - case "Pull": - processPullNotification(gitea, notification) - default: - gitea.SetNotificationRead(notification.ID) + log.Println(notification.ID, "--", notification.Subject) + + if !ListPullNotificationsOnly && (ProcessIDOnly < 0 || ProcessIDOnly == notification.ID) { + switch notification.Subject.Type { + case "Pull": + processPullNotification(gitea, notification) + default: + gitea.SetNotificationRead(notification.ID) + } } } } } +var ListPullNotificationsOnly bool +var ProcessIDOnly int64 +var Debug bool + func main() { + flag.BoolVar(&Debug, "debug", false, "One-shot run. Use for debugging") + flag.BoolVar(&ListPullNotificationsOnly, "list-notifications-only", false, "Only lists notifications without acting on them") + flag.Int64Var(&ProcessIDOnly, "id", -1, "Process only the specific ID and ignore the rest. Use for debugging") + flag.Parse() + failOnError(common.RequireGiteaSecretToken(), "Cannot find GITEA_TOKEN") failOnError(common.RequireObsSecretToken(), "Cannot find OBS_USER and OBS_PASSWORD") @@ -571,7 +584,9 @@ func main() { for { pollWorkNotifications(*giteaHost) + if Debug { + break + } time.Sleep(10 * time.Minute) } } -