This commit is contained in:
2025-07-08 14:54:41 +07:00
commit 644a6f9803
86 changed files with 12422 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
package models
import (
"errors"
"fmt"
"os"
"strconv"
"strings"
)
type BinaryVersion struct {
Major int
Minor int
Patch int
}
func ParseBinaryVersion(path string) (*BinaryVersion, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
content := string(data)
dashPos := strings.LastIndex(content, "-")
if dashPos == -1 {
return nil, errors.New("no dash found in version string")
}
start := dashPos - 6
if start < 0 {
start = 0
}
versionSlice := content[start:]
end := strings.Index(versionSlice, "-")
if end == -1 {
end = len(versionSlice)
}
versionStr := versionSlice[:end]
parts := strings.SplitN(versionStr, ".", 3)
if len(parts) != 3 {
return nil, errors.New("invalid version format")
}
major, err := strconv.Atoi(parts[0])
if err != nil {
return nil, err
}
minor, err := strconv.Atoi(parts[1])
if err != nil {
return nil, err
}
patch, err := strconv.Atoi(parts[2])
if err != nil {
return nil, err
}
return &BinaryVersion{major, minor, patch}, nil
}
func (v *BinaryVersion) String() string {
return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch)
}
func (v BinaryVersion) ToInt() int {
return v.Major*100 + v.Minor*10 + v.Patch
}
func (v BinaryVersion) Subtract(other BinaryVersion) int {
return v.ToInt() - other.ToInt()
}

15
pkg/models/hdiffmap.go Normal file
View File

@@ -0,0 +1,15 @@
package models
type DiffMapType struct {
SourceFileName string `json:"source_file_name"`
SourceFileMD5 string `json:"source_file_md5"`
SourceFileSize int64 `json:"source_file_size"`
TargetFileName string `json:"target_file_name"`
TargetFileMD5 string `json:"target_file_md5"`
TargetFileSize int64 `json:"target_file_size"`
PatchFileName string `json:"patch_file_name"`
PatchFileMD5 string `json:"patch_file_md5"`
PatchFileSize int64 `json:"patch_file_size"`
}

56
pkg/models/release.go Normal file
View File

@@ -0,0 +1,56 @@
package models
type ReleaseType struct {
ID int `json:"id"`
TagName string `json:"tag_name"`
TargetCommitish string `json:"target_commitish"`
Name string `json:"name"`
Body string `json:"body"`
URL string `json:"url"`
HTMLURL string `json:"html_url"`
TarballURL string `json:"tarball_url"`
ZipballURL string `json:"zipball_url"`
UploadURL string `json:"upload_url"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
CreatedAt string `json:"created_at"`
PublishedAt string `json:"published_at"`
Author AuthorType `json:"author"`
Assets []AssetType `json:"assets"`
}
type AuthorType struct {
ID int `json:"id"`
Login string `json:"login"`
LoginName string `json:"login_name"`
SourceID int `json:"source_id"`
FullName string `json:"full_name"`
Email string `json:"email"`
AvatarURL string `json:"avatar_url"`
HTMLURL string `json:"html_url"`
Language string `json:"language"`
IsAdmin bool `json:"is_admin"`
LastLogin string `json:"last_login"`
Created string `json:"created"`
Restricted bool `json:"restricted"`
Active bool `json:"active"`
ProhibitLogin bool `json:"prohibit_login"`
Location string `json:"location"`
Website string `json:"website"`
Description string `json:"description"`
Visibility string `json:"visibility"`
FollowersCount int `json:"followers_count"`
FollowingCount int `json:"following_count"`
StarredReposCount int `json:"starred_repos_count"`
Username string `json:"username"`
}
type AssetType struct {
ID int `json:"id"`
Name string `json:"name"`
Size int `json:"size"`
DownloadCount int `json:"download_count"`
CreatedAt string `json:"created_at"`
UUID string `json:"uuid"`
BrowserDownloadURL string `json:"browser_download_url"`
}