- Changed the build process to include a web UI build stage using Node.js. - Updated Go build stage to copy web UI files to the correct location. - Removed the main.go file as it is no longer needed. - Added SQLite database configuration to example config. - Updated dependencies in go.mod and go.sum, including new packages for JWT and SQLite. - Modified .gitignore to include new database and configuration files. Signed-off-by: zhenyus <zhenyus@mathmast.com>
58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
package model
|
|
|
|
// GiteaWebhook represents the webhook payload from Gitea
|
|
type GiteaWebhook struct {
|
|
Secret string `json:"secret"`
|
|
Ref string `json:"ref"`
|
|
Before string `json:"before"`
|
|
After string `json:"after"`
|
|
CompareURL string `json:"compare_url"`
|
|
Commits []Commit `json:"commits"`
|
|
Repository Repository `json:"repository"`
|
|
Pusher User `json:"pusher"`
|
|
}
|
|
|
|
// Commit represents a Git commit in the webhook payload
|
|
type Commit struct {
|
|
ID string `json:"id"`
|
|
Message string `json:"message"`
|
|
URL string `json:"url"`
|
|
Author User `json:"author"`
|
|
}
|
|
|
|
// Repository represents a Git repository in the webhook payload
|
|
type Repository struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name"`
|
|
Owner User `json:"owner"`
|
|
FullName string `json:"full_name"`
|
|
Private bool `json:"private"`
|
|
CloneURL string `json:"clone_url"`
|
|
SSHURL string `json:"ssh_url"`
|
|
HTMLURL string `json:"html_url"`
|
|
DefaultBranch string `json:"default_branch"`
|
|
}
|
|
|
|
// User represents a Gitea user in the webhook payload
|
|
type User struct {
|
|
ID int `json:"id"`
|
|
Login string `json:"login"`
|
|
FullName string `json:"full_name"`
|
|
Email string `json:"email,omitempty"`
|
|
Username string `json:"username,omitempty"`
|
|
}
|
|
|
|
// GetBranchName extracts the branch name from the ref
|
|
func (w *GiteaWebhook) GetBranchName() string {
|
|
const prefix = "refs/heads/"
|
|
if len(w.Ref) > len(prefix) {
|
|
return w.Ref[len(prefix):]
|
|
}
|
|
return w.Ref
|
|
}
|
|
|
|
// GetEventID generates a unique event ID for the webhook
|
|
func (w *GiteaWebhook) GetEventID() string {
|
|
return w.Repository.FullName + "-" + w.After
|
|
}
|