forked from Gitlink/gitea-1120-rc1
Compare commits
24 Commits
develop_wm
...
master
Author | SHA1 | Date |
---|---|---|
|
3e9b0dc1c5 | |
|
de0f7764c7 | |
|
15882844c6 | |
|
d78a760be7 | |
|
06dd55c49f | |
|
9ee3486d44 | |
|
52232e2431 | |
|
c37047eeaf | |
|
bfbd16b7df | |
|
b82b5bf80b | |
|
796c78996b | |
|
705694ff88 | |
|
6270454d59 | |
|
04f3e061cb | |
|
8f47d8df52 | |
|
dfc39ebda0 | |
|
ad3ccfb22f | |
|
4e0a133712 | |
|
9f80111504 | |
|
20c13e8352 | |
|
71df4fdfa1 | |
|
20e2cb271e | |
|
fdfe572500 | |
|
86fb4bb8d8 |
|
@ -96,6 +96,7 @@ func (r *Release) APIFormat() *api.Release {
|
||||||
TagName: r.TagName,
|
TagName: r.TagName,
|
||||||
Target: r.Target,
|
Target: r.Target,
|
||||||
Title: r.Title,
|
Title: r.Title,
|
||||||
|
Sha1: r.Sha1,
|
||||||
Note: r.Note,
|
Note: r.Note,
|
||||||
URL: r.APIURL(),
|
URL: r.APIURL(),
|
||||||
HTMLURL: r.HTMLURL(),
|
HTMLURL: r.HTMLURL(),
|
||||||
|
|
|
@ -30,8 +30,19 @@ func ToEmail(email *models.EmailAddress) *api.Email {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BranchKind int
|
||||||
|
|
||||||
|
const (
|
||||||
|
None BranchKind = iota
|
||||||
|
DefaultBranch
|
||||||
|
ProtectedBranch
|
||||||
|
OtherBranch
|
||||||
|
)
|
||||||
|
|
||||||
// ToBranch convert a git.Commit and git.Branch to an api.Branch
|
// ToBranch convert a git.Commit and git.Branch to an api.Branch
|
||||||
func ToBranch(repo *models.Repository, b *git.Branch, c *git.Commit, bp *models.ProtectedBranch, user *models.User, isRepoAdmin bool) (*api.Branch, error) {
|
func ToBranch(repo *models.Repository, b *git.Branch, c *git.Commit, bp *models.ProtectedBranch, user *models.User, isRepoAdmin bool) (*api.Branch, error) {
|
||||||
|
|
||||||
|
var branchKind BranchKind
|
||||||
if bp == nil {
|
if bp == nil {
|
||||||
var hasPerm bool
|
var hasPerm bool
|
||||||
var err error
|
var err error
|
||||||
|
@ -41,9 +52,15 @@ func ToBranch(repo *models.Repository, b *git.Branch, c *git.Commit, bp *models.
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if b.Name == repo.DefaultBranch {
|
||||||
|
branchKind = DefaultBranch
|
||||||
|
} else {
|
||||||
|
branchKind = OtherBranch
|
||||||
|
}
|
||||||
|
|
||||||
return &api.Branch{
|
return &api.Branch{
|
||||||
Name: b.Name,
|
Name: b.Name,
|
||||||
|
CommitID: c.ID.String(), //add configure
|
||||||
Commit: ToCommit(repo, c),
|
Commit: ToCommit(repo, c),
|
||||||
Protected: false,
|
Protected: false,
|
||||||
RequiredApprovals: 0,
|
RequiredApprovals: 0,
|
||||||
|
@ -51,16 +68,28 @@ func ToBranch(repo *models.Repository, b *git.Branch, c *git.Commit, bp *models.
|
||||||
StatusCheckContexts: []string{},
|
StatusCheckContexts: []string{},
|
||||||
UserCanPush: hasPerm,
|
UserCanPush: hasPerm,
|
||||||
UserCanMerge: hasPerm,
|
UserCanMerge: hasPerm,
|
||||||
|
CommitTime: c.Author.When.Format(time.RFC3339),
|
||||||
|
DefaultBranch: repo.DefaultBranch,
|
||||||
|
BranchKind: int(branchKind),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
if b.Name == repo.DefaultBranch {
|
||||||
|
branchKind = DefaultBranch
|
||||||
|
} else {
|
||||||
|
branchKind = ProtectedBranch
|
||||||
|
}
|
||||||
|
|
||||||
branch := &api.Branch{
|
branch := &api.Branch{
|
||||||
Name: b.Name,
|
Name: b.Name,
|
||||||
|
CommitID: c.ID.String(), // add configure
|
||||||
Commit: ToCommit(repo, c),
|
Commit: ToCommit(repo, c),
|
||||||
Protected: true,
|
Protected: true,
|
||||||
RequiredApprovals: bp.RequiredApprovals,
|
RequiredApprovals: bp.RequiredApprovals,
|
||||||
EnableStatusCheck: bp.EnableStatusCheck,
|
EnableStatusCheck: bp.EnableStatusCheck,
|
||||||
StatusCheckContexts: bp.StatusCheckContexts,
|
StatusCheckContexts: bp.StatusCheckContexts,
|
||||||
|
CommitTime: c.Author.When.Format(time.RFC3339),
|
||||||
|
DefaultBranch: repo.DefaultBranch,
|
||||||
|
BranchKind: int(branchKind),
|
||||||
}
|
}
|
||||||
|
|
||||||
if isRepoAdmin {
|
if isRepoAdmin {
|
||||||
|
@ -129,16 +158,42 @@ func ToBranchProtection(bp *models.ProtectedBranch) *api.BranchProtection {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToTag convert a git.Tag to an api.Tag
|
// ToTag convert a git.Tag to an api.Tag
|
||||||
|
// func ToTag(repo *models.Repository, t *git.Tag) *api.Tag {
|
||||||
|
// return &api.Tag{
|
||||||
|
// Name: t.Name,
|
||||||
|
// ID: t.ID.String(),
|
||||||
|
// Commit: ToCommitMeta(repo, t),
|
||||||
|
// ZipballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".zip"),
|
||||||
|
// TarballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".tar.gz"),
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
func ToTag(repo *models.Repository, t *git.Tag) *api.Tag {
|
func ToTag(repo *models.Repository, t *git.Tag) *api.Tag {
|
||||||
return &api.Tag{
|
return &api.Tag{
|
||||||
Name: t.Name,
|
Name: t.Name,
|
||||||
ID: t.ID.String(),
|
ID: t.ID.String(),
|
||||||
Commit: ToCommitMeta(repo, t),
|
Commit: ToTagCommit(repo, t),
|
||||||
|
Tagger: ToCommitUser(t.Tagger),
|
||||||
|
Message: t.Message,
|
||||||
ZipballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".zip"),
|
ZipballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".zip"),
|
||||||
TarballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".tar.gz"),
|
TarballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".tar.gz"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ToTagCommit(repo *models.Repository, t *git.Tag) *api.TagCommit {
|
||||||
|
commit, err := t.Commit()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Commit", err)
|
||||||
|
return &api.TagCommit{}
|
||||||
|
}
|
||||||
|
return &api.TagCommit{
|
||||||
|
CommitMeta: ToCommitMeta(repo, t),
|
||||||
|
Commiter: ToCommitUser(commit.Committer),
|
||||||
|
Author: ToCommitUser(commit.Author),
|
||||||
|
Message: commit.CommitMessage,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ToCommit convert a git.Commit to api.PayloadCommit
|
// ToCommit convert a git.Commit to api.PayloadCommit
|
||||||
func ToCommit(repo *models.Repository, c *git.Commit) *api.PayloadCommit {
|
func ToCommit(repo *models.Repository, c *git.Commit) *api.PayloadCommit {
|
||||||
authorUsername := ""
|
authorUsername := ""
|
||||||
|
@ -424,6 +479,16 @@ func ToCommitMeta(repo *models.Repository, tag *git.Tag) *api.CommitMeta {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ToCommitUserFolk(user *models.User) *api.CommitUser {
|
||||||
|
return &api.CommitUser{
|
||||||
|
Identity: api.Identity{
|
||||||
|
Name: user.Name,
|
||||||
|
Email: user.Email,
|
||||||
|
},
|
||||||
|
Date: user.CreatedUnix.AsTime().String(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ToTopicResponse convert from models.Topic to api.TopicResponse
|
// ToTopicResponse convert from models.Topic to api.TopicResponse
|
||||||
func ToTopicResponse(topic *models.Topic) *api.TopicResponse {
|
func ToTopicResponse(topic *models.Topic) *api.TopicResponse {
|
||||||
return &api.TopicResponse{
|
return &api.TopicResponse{
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
package convert
|
package convert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"code.gitea.io/gitea/modules/structs"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ToCorrectPageSize makes sure page size is in allowed range.
|
// ToCorrectPageSize makes sure page size is in allowed range.
|
||||||
|
@ -17,3 +20,36 @@ func ToCorrectPageSize(size int) int {
|
||||||
}
|
}
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ToGitServiceType return GitServiceType based on string
|
||||||
|
func ToGitServiceType(value string) structs.GitServiceType {
|
||||||
|
switch strings.ToLower(value) {
|
||||||
|
case "github":
|
||||||
|
return structs.GithubService
|
||||||
|
case "gitea":
|
||||||
|
return structs.GiteaService
|
||||||
|
case "gitlab":
|
||||||
|
return structs.GitlabService
|
||||||
|
case "gogs":
|
||||||
|
return structs.GogsService
|
||||||
|
default:
|
||||||
|
return structs.PlainGitService
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
func ToBranchType(index int) structs.BranchKind{
|
||||||
|
switch(index){
|
||||||
|
case 1:
|
||||||
|
return structs.DefaultBranch
|
||||||
|
case 2:
|
||||||
|
return structs.ProtectedBranch
|
||||||
|
case 3:
|
||||||
|
return structs.OtherBranch
|
||||||
|
default:
|
||||||
|
return structs.None
|
||||||
|
}
|
||||||
|
}
|
|
@ -293,6 +293,11 @@ func CommitsCount(repoPath, revision string) (int64, error) {
|
||||||
return commitsCount(repoPath, []string{revision}, []string{})
|
return commitsCount(repoPath, []string{revision}, []string{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommitsCountByFile returns number of total commits of unitl given revision and file
|
||||||
|
func CommitsCountByFile(repoPath, revision, file string) (int64, error) {
|
||||||
|
return commitsCount(repoPath, []string{revision}, []string{file})
|
||||||
|
}
|
||||||
|
|
||||||
// CommitsCount returns number of total commits of until current revision.
|
// CommitsCount returns number of total commits of until current revision.
|
||||||
func (c *Commit) CommitsCount() (int64, error) {
|
func (c *Commit) CommitsCount() (int64, error) {
|
||||||
return CommitsCount(c.repo.Path, c.ID.String())
|
return CommitsCount(c.repo.Path, c.ID.String())
|
||||||
|
@ -303,6 +308,11 @@ func (c *Commit) CommitsByRange(page, pageSize int) (*list.List, error) {
|
||||||
return c.repo.commitsByRange(c.ID, page, pageSize)
|
return c.repo.commitsByRange(c.ID, page, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommitsByFileAndRange returns the specific page page commits before current revision and file, every page's number default by CommitsRangeSize
|
||||||
|
func (c *Commit) CommitsByFileAndRange(file string, page, pageSize int) (*list.List, error) {
|
||||||
|
return c.repo.CommitsByFileAndRange(c.ID.String(), file, page, pageSize)
|
||||||
|
}
|
||||||
|
|
||||||
// CommitsBefore returns all the commits before current revision
|
// CommitsBefore returns all the commits before current revision
|
||||||
func (c *Commit) CommitsBefore() (*list.List, error) {
|
func (c *Commit) CommitsBefore() (*list.List, error) {
|
||||||
return c.repo.getCommitsBefore(c.ID)
|
return c.repo.getCommitsBefore(c.ID)
|
||||||
|
|
|
@ -335,8 +335,8 @@ func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsByFileAndRange return the commits according revison file and the page
|
// CommitsByFileAndRange return the commits according revison file and the page
|
||||||
func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) {
|
func (repo *Repository) CommitsByFileAndRange(revision, file string, page, pageSize int) (*list.List, error) {
|
||||||
stdout, err := NewCommand("log", revision, "--follow", "--skip="+strconv.Itoa((page-1)*50),
|
stdout, err := NewCommand("log", revision, "--follow", "--skip="+strconv.Itoa((page-1)*pageSize),
|
||||||
"--max-count="+strconv.Itoa(CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path)
|
"--max-count="+strconv.Itoa(CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -345,8 +345,8 @@ func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitsByFileAndRangeNoFollow return the commits according revison file and the page
|
// CommitsByFileAndRangeNoFollow return the commits according revison file and the page
|
||||||
func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page int) (*list.List, error) {
|
func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page, pageSize int) (*list.List, error) {
|
||||||
stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*50),
|
stdout, err := NewCommand("log", revision, "--skip="+strconv.Itoa((page-1)*pageSize),
|
||||||
"--max-count="+strconv.Itoa(CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path)
|
"--max-count="+strconv.Itoa(CommitsRangeSize), prettyLogFormat, "--", file).RunInDirBytes(repo.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -186,6 +186,16 @@ func (repo *Repository) GetTag(name string) (*Tag, error) {
|
||||||
return tag, nil
|
return tag, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *Repository) GetTagCount() (int64, error) {
|
||||||
|
stdout, err := NewCommand("tag").RunInDir(repo.Path)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
tagNames := strings.Split(strings.TrimRight(stdout, "\n"), "\n")
|
||||||
|
return int64(len(tagNames)), nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetTagInfos returns all tag infos of the repository.
|
// GetTagInfos returns all tag infos of the repository.
|
||||||
func (repo *Repository) GetTagInfos(page, pageSize int) ([]*Tag, error) {
|
func (repo *Repository) GetTagInfos(page, pageSize int) ([]*Tag, error) {
|
||||||
// TODO this a slow implementation, makes one git command per tag
|
// TODO this a slow implementation, makes one git command per tag
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/*
|
||||||
|
* @Description: Do not edit
|
||||||
|
* @Date: 2021-07-09 10:47:30
|
||||||
|
* @LastEditors: viletyy
|
||||||
|
* @Author: viletyy
|
||||||
|
* @LastEditTime: 2021-09-27 16:46:33
|
||||||
|
* @FilePath: /gitea-1120-rc1/modules/structs/release.go
|
||||||
|
*/
|
||||||
// Copyright 2016 The Gitea Authors. All rights reserved.
|
// Copyright 2016 The Gitea Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
@ -14,6 +22,7 @@ type Release struct {
|
||||||
TagName string `json:"tag_name"`
|
TagName string `json:"tag_name"`
|
||||||
Target string `json:"target_commitish"`
|
Target string `json:"target_commitish"`
|
||||||
Title string `json:"name"`
|
Title string `json:"name"`
|
||||||
|
Sha1 string `json:"sha"`
|
||||||
Note string `json:"body"`
|
Note string `json:"body"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
HTMLURL string `json:"html_url"`
|
HTMLURL string `json:"html_url"`
|
||||||
|
|
|
@ -5,12 +5,14 @@
|
||||||
package structs
|
package structs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Branch represents a repository branch
|
// Branch represents a repository branch
|
||||||
type Branch struct {
|
type Branch struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
CommitID string `json:"commit_id"` // add configure
|
||||||
Commit *PayloadCommit `json:"commit"`
|
Commit *PayloadCommit `json:"commit"`
|
||||||
Protected bool `json:"protected"`
|
Protected bool `json:"protected"`
|
||||||
RequiredApprovals int64 `json:"required_approvals"`
|
RequiredApprovals int64 `json:"required_approvals"`
|
||||||
|
@ -19,7 +21,56 @@ type Branch struct {
|
||||||
UserCanPush bool `json:"user_can_push"`
|
UserCanPush bool `json:"user_can_push"`
|
||||||
UserCanMerge bool `json:"user_can_merge"`
|
UserCanMerge bool `json:"user_can_merge"`
|
||||||
EffectiveBranchProtectionName string `json:"effective_branch_protection_name"`
|
EffectiveBranchProtectionName string `json:"effective_branch_protection_name"`
|
||||||
|
CommitTime string `json:"commit_time"` // add configure
|
||||||
|
DefaultBranch string `json:"default_branch"`
|
||||||
|
BranchKind int `json:"branch_kind"`
|
||||||
}
|
}
|
||||||
|
type BranchKind int
|
||||||
|
const (
|
||||||
|
|
||||||
|
None BranchKind = iota
|
||||||
|
DefaultBranch
|
||||||
|
ProtectedBranch
|
||||||
|
OtherBranch
|
||||||
|
)
|
||||||
|
func (bk BranchKind) Name() string{
|
||||||
|
return strings.ToLower(bk.Title())
|
||||||
|
}
|
||||||
|
func (bk BranchKind) Title() string {
|
||||||
|
switch bk {
|
||||||
|
case DefaultBranch:
|
||||||
|
return "default"
|
||||||
|
case ProtectedBranch:
|
||||||
|
return "protected"
|
||||||
|
case OtherBranch:
|
||||||
|
return "other"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type BranchesSlice struct {
|
||||||
|
|
||||||
|
BranchName string `json:"branch_name"`
|
||||||
|
// BranchKind int `json:"branch_kind"`
|
||||||
|
Branches []Branch `json:"branches"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort by branchkind
|
||||||
|
type SortBranch []Branch
|
||||||
|
func (s SortBranch) Len() int { return len(s) }
|
||||||
|
func (s SortBranch) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
func (s SortBranch) Less(i, j int) bool { return s[i].BranchKind < s[j].BranchKind}
|
||||||
|
|
||||||
|
// sort by CommiTime of the branch
|
||||||
|
type SortBranchTime []Branch
|
||||||
|
func (s SortBranchTime) Len() int { return len(s) }
|
||||||
|
func (s SortBranchTime) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
func (s SortBranchTime) Less(i, j int) bool { return s[i].CommitTime > s[j].CommitTime}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// BranchProtection represents a branch protection for a repository
|
// BranchProtection represents a branch protection for a repository
|
||||||
type BranchProtection struct {
|
type BranchProtection struct {
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/*
|
||||||
|
* @Description: Do not edit
|
||||||
|
* @Date: 2021-09-07 17:24:32
|
||||||
|
* @LastEditors: viletyy
|
||||||
|
* @Author: viletyy
|
||||||
|
* @LastEditTime: 2021-09-29 10:16:48
|
||||||
|
* @FilePath: /gitea-1120-rc1/modules/structs/repo_commit.go
|
||||||
|
*/
|
||||||
// Copyright 2018 The Gogs Authors. All rights reserved.
|
// Copyright 2018 The Gogs Authors. All rights reserved.
|
||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
|
@ -38,6 +46,7 @@ type RepoCommit struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit contains information generated from a Git commit.
|
// Commit contains information generated from a Git commit.
|
||||||
|
type SortCommit []Commit
|
||||||
type Commit struct {
|
type Commit struct {
|
||||||
*CommitMeta
|
*CommitMeta
|
||||||
HTMLURL string `json:"html_url"`
|
HTMLURL string `json:"html_url"`
|
||||||
|
@ -45,8 +54,19 @@ type Commit struct {
|
||||||
Author *User `json:"author"`
|
Author *User `json:"author"`
|
||||||
Committer *User `json:"committer"`
|
Committer *User `json:"committer"`
|
||||||
Parents []*CommitMeta `json:"parents"`
|
Parents []*CommitMeta `json:"parents"`
|
||||||
|
CommitDate string `json:"commit_date"`
|
||||||
|
Branch string `json:"branch"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CommitsSlice struct {
|
||||||
|
CommitDate string `json:"commit_date"`
|
||||||
|
Commits []Commit
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SortCommit) Len() int { return len(s) }
|
||||||
|
func (s SortCommit) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
func (s SortCommit) Less(i, j int) bool { return s[i].CommitDate > s[j].CommitDate }
|
||||||
|
|
||||||
// CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE
|
// CommitDateOptions store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE
|
||||||
type CommitDateOptions struct {
|
type CommitDateOptions struct {
|
||||||
// swagger:strfmt date-time
|
// swagger:strfmt date-time
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/*
|
||||||
|
* @Description: Do not edit
|
||||||
|
* @Date: 2021-09-23 17:10:03
|
||||||
|
* @LastEditors: viletyy
|
||||||
|
* @Author: viletyy
|
||||||
|
* @LastEditTime: 2021-09-24 17:45:38
|
||||||
|
* @FilePath: /gitea-1120-rc1/modules/structs/repo_tag.go
|
||||||
|
*/
|
||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
@ -8,11 +16,20 @@ package structs
|
||||||
type Tag struct {
|
type Tag struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Commit *CommitMeta `json:"commit"`
|
Commit *TagCommit `json:"commit"`
|
||||||
|
Tagger *CommitUser `json:"tagger"`
|
||||||
|
Message string `json:"message"`
|
||||||
ZipballURL string `json:"zipball_url"`
|
ZipballURL string `json:"zipball_url"`
|
||||||
TarballURL string `json:"tarball_url"`
|
TarballURL string `json:"tarball_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TagCommit struct {
|
||||||
|
*CommitMeta
|
||||||
|
Commiter *CommitUser `json:"commiter"`
|
||||||
|
Author *CommitUser `json:"author"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
// AnnotatedTag represents an annotated tag
|
// AnnotatedTag represents an annotated tag
|
||||||
type AnnotatedTag struct {
|
type AnnotatedTag struct {
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
|
|
|
@ -89,11 +89,6 @@ import (
|
||||||
"gitea.com/macaron/macaron"
|
"gitea.com/macaron/macaron"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func MustEnableWiki(ctx *context.Context) {
|
func MustEnableWiki(ctx *context.Context) {
|
||||||
if !ctx.Repo.CanRead(models.UnitTypeWiki) &&
|
if !ctx.Repo.CanRead(models.UnitTypeWiki) &&
|
||||||
!ctx.Repo.CanRead(models.UnitTypeExternalWiki) {
|
!ctx.Repo.CanRead(models.UnitTypeExternalWiki) {
|
||||||
|
@ -704,7 +699,9 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
|
|
||||||
// alter on 2021/01/15
|
// alter on 2021/01/15
|
||||||
m.Get("", viewfile.Readme) // reqRepoReader(models.UnitTypeCode),
|
m.Get("", viewfile.Readme) // reqRepoReader(models.UnitTypeCode),
|
||||||
}, reqToken())
|
m.Get("/*", viewfile.ReadmeByPath) // reqRepoReader(models.UnitTypeCode),
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
m.Group("/count", func() {
|
m.Group("/count", func() {
|
||||||
m.Get("", viewfile.CommitCount) //****
|
m.Get("", viewfile.CommitCount) //****
|
||||||
|
@ -795,6 +792,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
Post(reqToken(), reqRepoReader(models.UnitTypeCode), bind(api.CreateForkOption{}), repo.CreateFork)
|
Post(reqToken(), reqRepoReader(models.UnitTypeCode), bind(api.CreateForkOption{}), repo.CreateFork)
|
||||||
m.Group("/branches", func() {
|
m.Group("/branches", func() {
|
||||||
m.Get("", repo.ListBranches)
|
m.Get("", repo.ListBranches)
|
||||||
|
m.Get("/branches_slice", repo.ListBranchesSlice)
|
||||||
m.Get("/*", context.RepoRefByType(context.RepoRefBranch), repo.GetBranch)
|
m.Get("/*", context.RepoRefByType(context.RepoRefBranch), repo.GetBranch)
|
||||||
m.Delete("/*", reqRepoWriter(models.UnitTypeCode), context.RepoRefByType(context.RepoRefBranch), repo.DeleteBranch)
|
m.Delete("/*", reqRepoWriter(models.UnitTypeCode), context.RepoRefByType(context.RepoRefBranch), repo.DeleteBranch)
|
||||||
m.Post("", reqRepoWriter(models.UnitTypeCode), bind(api.CreateBranchRepoOption{}), repo.CreateBranch)
|
m.Post("", reqRepoWriter(models.UnitTypeCode), bind(api.CreateBranchRepoOption{}), repo.CreateBranch)
|
||||||
|
@ -951,11 +949,16 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
}, reqRepoReader(models.UnitTypeCode))
|
}, reqRepoReader(models.UnitTypeCode))
|
||||||
m.Group("/commits", func() {
|
m.Group("/commits", func() {
|
||||||
m.Get("", repo.GetAllCommits)
|
m.Get("", repo.GetAllCommits)
|
||||||
|
|
||||||
m.Group("/:ref", func() {
|
m.Group("/:ref", func() {
|
||||||
m.Get("/status", repo.GetCombinedCommitStatusByRef)
|
m.Get("/status", repo.GetCombinedCommitStatusByRef)
|
||||||
m.Get("/statuses", repo.GetCommitStatusesByRef)
|
m.Get("/statuses", repo.GetCommitStatusesByRef)
|
||||||
})
|
})
|
||||||
}, reqRepoReader(models.UnitTypeCode))
|
}, reqRepoReader(models.UnitTypeCode))
|
||||||
|
m.Get("/commits_slice", repo.GetAllCommitsSliceByTime)
|
||||||
|
m.Group("/file_commits", func() {
|
||||||
|
m.Get("/*", repo.GetFileAllCommits)
|
||||||
|
})
|
||||||
m.Group("/git", func() {
|
m.Group("/git", func() {
|
||||||
m.Group("/commits", func() {
|
m.Group("/commits", func() {
|
||||||
m.Get("/:sha", repo.GetSingleCommit)
|
m.Get("/:sha", repo.GetSingleCommit)
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/convert"
|
"code.gitea.io/gitea/modules/convert"
|
||||||
|
@ -14,8 +18,6 @@ import (
|
||||||
"code.gitea.io/gitea/modules/repofiles"
|
"code.gitea.io/gitea/modules/repofiles"
|
||||||
repo_module "code.gitea.io/gitea/modules/repository"
|
repo_module "code.gitea.io/gitea/modules/repository"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetBranch get a branch of a repository
|
// GetBranch get a branch of a repository
|
||||||
|
@ -45,8 +47,6 @@ func GetBranch(ctx *context.APIContext) {
|
||||||
// "200":
|
// "200":
|
||||||
// "$ref": "#/responses/Branch"
|
// "$ref": "#/responses/Branch"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ctx.Repo.TreePath != "" {
|
if ctx.Repo.TreePath != "" {
|
||||||
// if TreePath != "", then URL contained extra slashes
|
// if TreePath != "", then URL contained extra slashes
|
||||||
// (i.e. "master/subbranch" instead of "master"), so branch does
|
// (i.e. "master/subbranch" instead of "master"), so branch does
|
||||||
|
@ -328,6 +328,92 @@ func ListBranches(ctx *context.APIContext) {
|
||||||
ctx.JSON(http.StatusOK, &apiBranches)
|
ctx.JSON(http.StatusOK, &apiBranches)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListBranches list all the branches of a repository
|
||||||
|
func ListBranchesSlice(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/branches/branches_slice repository repoListBranchesSlice
|
||||||
|
// ---
|
||||||
|
// summary: List a repository's branches, Group sort.
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/BranchList"
|
||||||
|
|
||||||
|
//start:=time.Now()
|
||||||
|
branches, err := repo_module.GetBranches(ctx.Repo.Repository)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, "GetBranches", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//fmt.Println("***************** *GetBranches:",time.Now().Sub(start)," ",branches,len(branches))
|
||||||
|
|
||||||
|
apiBranches := make([]*api.Branch, len(branches))
|
||||||
|
|
||||||
|
// add configure
|
||||||
|
apiBranchesList := []api.Branch{}
|
||||||
|
for i := range branches {
|
||||||
|
c, err := branches[i].GetCommit()
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//fmt.Println("****branches[i]:",branches[i])
|
||||||
|
branchProtection, err := ctx.Repo.Repository.GetBranchProtection(branches[i].Name)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//fmt.Println("****branchProtection:",branchProtection)
|
||||||
|
apiBranches[i], err = convert.ToBranch(ctx.Repo.Repository, branches[i], c, branchProtection, ctx.User, ctx.Repo.IsAdmin())
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, "convert.ToBranch", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
apiBranchesList = append(apiBranchesList, *apiBranches[i])
|
||||||
|
//fmt.Println("****apiBranches[i]:",apiBranches[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.JSON(http.StatusOK, BranchesSliceByProtection(ctx, apiBranchesList))
|
||||||
|
}
|
||||||
|
|
||||||
|
// branches slice. Group by protection
|
||||||
|
|
||||||
|
func BranchesSliceByProtection(ctx *context.APIContext, branchList []api.Branch) []api.BranchesSlice {
|
||||||
|
// group by protection
|
||||||
|
sort.Sort(api.SortBranch(branchList))
|
||||||
|
branchSlice := make([]api.BranchesSlice, 0)
|
||||||
|
i := 0
|
||||||
|
var j int
|
||||||
|
for {
|
||||||
|
if i >= len(branchList) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
for j = i + 1; j < len(branchList) && (branchList[i].BranchKind == branchList[j].BranchKind); j++ {
|
||||||
|
}
|
||||||
|
// get the same branches
|
||||||
|
sameBranchSlice := branchList[i:j]
|
||||||
|
// sort by time
|
||||||
|
sort.Sort(api.SortBranchTime(sameBranchSlice))
|
||||||
|
branchSlice = append(branchSlice, api.BranchesSlice{
|
||||||
|
BranchName: convert.ToBranchType(branchList[i].BranchKind).Name(),
|
||||||
|
Branches: sameBranchSlice,
|
||||||
|
})
|
||||||
|
i = j
|
||||||
|
}
|
||||||
|
return branchSlice
|
||||||
|
}
|
||||||
|
|
||||||
// GetBranchProtection gets a branch protection
|
// GetBranchProtection gets a branch protection
|
||||||
func GetBranchProtection(ctx *context.APIContext) {
|
func GetBranchProtection(ctx *context.APIContext) {
|
||||||
// swagger:operation GET /repos/{owner}/{repo}/branch_protections/{name} repository repoGetBranchProtection
|
// swagger:operation GET /repos/{owner}/{repo}/branch_protections/{name} repository repoGetBranchProtection
|
||||||
|
|
|
@ -9,18 +9,19 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
|
||||||
"code.gitea.io/gitea/modules/gitgraph"
|
"code.gitea.io/gitea/modules/gitgraph"
|
||||||
"code.gitea.io/gitea/services/gitdiff"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/modules/validation"
|
"code.gitea.io/gitea/modules/validation"
|
||||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||||
|
"code.gitea.io/gitea/services/gitdiff"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetSingleCommit get a commit via sha
|
// GetSingleCommit get a commit via sha
|
||||||
|
@ -83,6 +84,140 @@ func getCommit(ctx *context.APIContext, identifier string) {
|
||||||
ctx.JSON(http.StatusOK, json)
|
ctx.JSON(http.StatusOK, json)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetFileCommits get all commits by path on a repository
|
||||||
|
func GetFileAllCommits(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/file_commits/{filepath} repository repoGetFileAllCommits
|
||||||
|
// ---
|
||||||
|
// summary: Get a list of all commits by filepath from a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: filepath
|
||||||
|
// in: path
|
||||||
|
// description: filepath of the file to get
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: sha
|
||||||
|
// in: query
|
||||||
|
// description: SHA or branch to start listing commits from (usually 'master')
|
||||||
|
// type: string
|
||||||
|
// - name: page
|
||||||
|
// in: query
|
||||||
|
// description: page number of results to return (1-based)
|
||||||
|
// type: integer
|
||||||
|
// - name: limit
|
||||||
|
// in: query
|
||||||
|
// description: page size of results
|
||||||
|
// type: integer
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/FileCommitList"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
|
// "409":
|
||||||
|
// "$ref": "#/responses/EmptyRepository"
|
||||||
|
|
||||||
|
if ctx.Repo.Repository.IsEmpty {
|
||||||
|
ctx.JSON(http.StatusConflict, api.APIError{
|
||||||
|
Message: "Git Repository is empty.",
|
||||||
|
URL: setting.API.SwaggerURL,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
gitRepo, err := git.OpenRepository(ctx.Repo.Repository.RepoPath())
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("OpenRepository", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer gitRepo.Close()
|
||||||
|
|
||||||
|
listOptions := utils.GetListOptions(ctx)
|
||||||
|
if listOptions.Page <= 0 {
|
||||||
|
listOptions.Page = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if listOptions.PageSize > git.CommitsRangeSize {
|
||||||
|
listOptions.PageSize = git.CommitsRangeSize
|
||||||
|
}
|
||||||
|
|
||||||
|
sha := ctx.Query("sha")
|
||||||
|
treePath := ctx.Params("*")
|
||||||
|
var baseCommit *git.Commit
|
||||||
|
var commitsCountTotal int64
|
||||||
|
if len(sha) == 0 {
|
||||||
|
head, err := gitRepo.GetHEADBranch()
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetHEADBranch", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
baseCommit, err = gitRepo.GetBranchCommit(head.Name)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetCommit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
commitsCountTotal, err = git.CommitsCountByFile(gitRepo.Path, head.Name, treePath)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("CommitsCount", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
baseCommit, err = gitRepo.GetCommit(sha)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetCommit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
commitsCountTotal, err = git.CommitsCountByFile(gitRepo.Path, sha, treePath)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("CommitsCount", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pageCount := int(math.Ceil(float64(commitsCountTotal) / float64(listOptions.PageSize)))
|
||||||
|
|
||||||
|
commits, err := baseCommit.CommitsByFileAndRange(treePath, listOptions.Page, listOptions.PageSize)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("CommitsByRange", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
userCache := make(map[string]*models.User)
|
||||||
|
apiCommits := make([]*api.Commit, commits.Len())
|
||||||
|
i := 0
|
||||||
|
for commitPointer := commits.Front(); commitPointer != nil; commitPointer = commitPointer.Next() {
|
||||||
|
commit := commitPointer.Value.(*git.Commit)
|
||||||
|
apiCommits[i], err = toCommit(ctx, ctx.Repo.Repository, commit, userCache)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("toCommit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Header().Set("X-Page", strconv.Itoa(listOptions.Page))
|
||||||
|
ctx.Header().Set("X-PerPage", strconv.Itoa(listOptions.PageSize))
|
||||||
|
ctx.Header().Set("X-Total", strconv.FormatInt(commitsCountTotal, 10))
|
||||||
|
ctx.Header().Set("X-PageCount", strconv.Itoa(pageCount))
|
||||||
|
ctx.Header().Set("X-HasMore", strconv.FormatBool(listOptions.Page < pageCount))
|
||||||
|
ctx.SetLinkHeader(int(commitsCountTotal), listOptions.PageSize)
|
||||||
|
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", commitsCountTotal))
|
||||||
|
|
||||||
|
ctx.JSON(http.StatusOK, apiCommits)
|
||||||
|
}
|
||||||
|
|
||||||
// GetAllCommits get all commits via
|
// GetAllCommits get all commits via
|
||||||
func GetAllCommits(ctx *context.APIContext) {
|
func GetAllCommits(ctx *context.APIContext) {
|
||||||
// swagger:operation GET /repos/{owner}/{repo}/commits repository repoGetAllCommits
|
// swagger:operation GET /repos/{owner}/{repo}/commits repository repoGetAllCommits
|
||||||
|
@ -189,7 +324,10 @@ func GetAllCommits(ctx *context.APIContext) {
|
||||||
userCache := make(map[string]*models.User)
|
userCache := make(map[string]*models.User)
|
||||||
|
|
||||||
apiCommits := make([]*api.Commit, commits.Len())
|
apiCommits := make([]*api.Commit, commits.Len())
|
||||||
|
// =============================================================
|
||||||
|
// apiCommitsList := []api.Commit{}
|
||||||
|
|
||||||
|
// =================================================================
|
||||||
i := 0
|
i := 0
|
||||||
for commitPointer := commits.Front(); commitPointer != nil; commitPointer = commitPointer.Next() {
|
for commitPointer := commits.Front(); commitPointer != nil; commitPointer = commitPointer.Next() {
|
||||||
commit := commitPointer.Value.(*git.Commit)
|
commit := commitPointer.Value.(*git.Commit)
|
||||||
|
@ -200,6 +338,7 @@ func GetAllCommits(ctx *context.APIContext) {
|
||||||
ctx.ServerError("toCommit", err)
|
ctx.ServerError("toCommit", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// apiCommitsList = append(apiCommitsList,*apiCommits[i])
|
||||||
|
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
@ -214,7 +353,168 @@ func GetAllCommits(ctx *context.APIContext) {
|
||||||
ctx.SetLinkHeader(int(commitsCountTotal), listOptions.PageSize)
|
ctx.SetLinkHeader(int(commitsCountTotal), listOptions.PageSize)
|
||||||
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", commitsCountTotal))
|
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", commitsCountTotal))
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, &apiCommits)
|
ctx.JSON(http.StatusOK, apiCommits)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllCommits get all commits via
|
||||||
|
func GetAllCommitsSliceByTime(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/commits_slice repository repoGetAllCommitsSlice
|
||||||
|
// ---
|
||||||
|
// summary: Get a list of all commits from a repository
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: sha
|
||||||
|
// in: query
|
||||||
|
// description: SHA or branch to start listing commits from (usually 'master')
|
||||||
|
// type: string
|
||||||
|
// - name: page
|
||||||
|
// in: query
|
||||||
|
// description: page number of results to return (1-based)
|
||||||
|
// type: integer
|
||||||
|
// - name: limit
|
||||||
|
// in: query
|
||||||
|
// description: page size of results
|
||||||
|
// type: integer
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/CommitList"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
|
// "409":
|
||||||
|
// "$ref": "#/responses/EmptyRepository"
|
||||||
|
|
||||||
|
if ctx.Repo.Repository.IsEmpty {
|
||||||
|
ctx.JSON(http.StatusConflict, api.APIError{
|
||||||
|
Message: "Git Repository is empty.",
|
||||||
|
URL: setting.API.SwaggerURL,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
gitRepo, err := git.OpenRepository(ctx.Repo.Repository.RepoPath())
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("OpenRepository", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer gitRepo.Close()
|
||||||
|
|
||||||
|
listOptions := utils.GetListOptions(ctx)
|
||||||
|
if listOptions.Page <= 0 {
|
||||||
|
listOptions.Page = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if listOptions.PageSize > git.CommitsRangeSize {
|
||||||
|
listOptions.PageSize = git.CommitsRangeSize
|
||||||
|
}
|
||||||
|
|
||||||
|
sha := ctx.Query("sha")
|
||||||
|
|
||||||
|
var baseCommit *git.Commit
|
||||||
|
if len(sha) == 0 {
|
||||||
|
// no sha supplied - use default branch
|
||||||
|
head, err := gitRepo.GetHEADBranch()
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetHEADBranch", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
baseCommit, err = gitRepo.GetBranchCommit(head.Name)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetCommit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// get commit specified by sha
|
||||||
|
baseCommit, err = gitRepo.GetCommit(sha)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetCommit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Total commit count
|
||||||
|
commitsCountTotal, err := baseCommit.CommitsCount()
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetCommitsCount", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pageCount := int(math.Ceil(float64(commitsCountTotal) / float64(listOptions.PageSize)))
|
||||||
|
|
||||||
|
// Query commits
|
||||||
|
commits, err := baseCommit.CommitsByRange(listOptions.Page, listOptions.PageSize)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("CommitsByRange", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
userCache := make(map[string]*models.User)
|
||||||
|
|
||||||
|
apiCommits := make([]*api.Commit, commits.Len())
|
||||||
|
apiCommitsList := []api.Commit{}
|
||||||
|
i := 0
|
||||||
|
for commitPointer := commits.Front(); commitPointer != nil; commitPointer = commitPointer.Next() {
|
||||||
|
commit := commitPointer.Value.(*git.Commit)
|
||||||
|
|
||||||
|
// Create json struct
|
||||||
|
apiCommits[i], err = toCommit(ctx, ctx.Repo.Repository, commit, userCache)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("toCommit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
apiCommitsList = append(apiCommitsList, *apiCommits[i])
|
||||||
|
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
|
||||||
|
// kept for backwards compatibility
|
||||||
|
ctx.Header().Set("X-Page", strconv.Itoa(listOptions.Page))
|
||||||
|
ctx.Header().Set("X-PerPage", strconv.Itoa(listOptions.PageSize))
|
||||||
|
ctx.Header().Set("X-Total", strconv.FormatInt(commitsCountTotal, 10))
|
||||||
|
ctx.Header().Set("X-PageCount", strconv.Itoa(pageCount))
|
||||||
|
ctx.Header().Set("X-HasMore", strconv.FormatBool(listOptions.Page < pageCount))
|
||||||
|
|
||||||
|
ctx.SetLinkHeader(int(commitsCountTotal), listOptions.PageSize)
|
||||||
|
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", commitsCountTotal))
|
||||||
|
|
||||||
|
ctx.JSON(http.StatusOK, CommitSplitSlice(apiCommitsList))
|
||||||
|
}
|
||||||
|
|
||||||
|
func CommitSplitSlice(CommitsList []api.Commit) []api.CommitsSlice {
|
||||||
|
// sort by time
|
||||||
|
sort.Sort(api.SortCommit(CommitsList))
|
||||||
|
Commits := make([]api.CommitsSlice, 0)
|
||||||
|
i := 0
|
||||||
|
var j int
|
||||||
|
for {
|
||||||
|
if i >= len(CommitsList) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
// Detect equal CommitData,
|
||||||
|
for j = i + 1; j < len(CommitsList) && CommitsList[i].CommitDate == CommitsList[j].CommitDate; j++ {
|
||||||
|
}
|
||||||
|
// if equal, put commitdata in an array
|
||||||
|
commitDate := CommitsList[i].CommitDate
|
||||||
|
commitDatalist := CommitsList[i:j]
|
||||||
|
i = j // variable value
|
||||||
|
// get all the values,,,Commits
|
||||||
|
Commits = append(Commits, api.CommitsSlice{
|
||||||
|
CommitDate: commitDate,
|
||||||
|
Commits: commitDatalist,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return Commits
|
||||||
}
|
}
|
||||||
|
|
||||||
func toCommit(ctx *context.APIContext, repo *models.Repository, commit *git.Commit, userCache map[string]*models.User) (*api.Commit, error) {
|
func toCommit(ctx *context.APIContext, repo *models.Repository, commit *git.Commit, userCache map[string]*models.User) (*api.Commit, error) {
|
||||||
|
@ -277,8 +577,9 @@ func toCommit(ctx *context.APIContext, repo *models.Repository, commit *git.Comm
|
||||||
SHA: sha.String(),
|
SHA: sha.String(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
commit.LoadBranchName()
|
||||||
return &api.Commit{
|
return &api.Commit{
|
||||||
|
CommitDate: commit.Committer.When.Format("2006-01-02"), // new time format, year-moon-day
|
||||||
CommitMeta: &api.CommitMeta{
|
CommitMeta: &api.CommitMeta{
|
||||||
URL: repo.APIURL() + "/git/commits/" + commit.ID.String(),
|
URL: repo.APIURL() + "/git/commits/" + commit.ID.String(),
|
||||||
SHA: commit.ID.String(),
|
SHA: commit.ID.String(),
|
||||||
|
@ -309,14 +610,16 @@ func toCommit(ctx *context.APIContext, repo *models.Repository, commit *git.Comm
|
||||||
Author: apiAuthor,
|
Author: apiAuthor,
|
||||||
Committer: apiCommitter,
|
Committer: apiCommitter,
|
||||||
Parents: apiParents,
|
Parents: apiParents,
|
||||||
|
Branch: commit.Branch,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// add by qiubing
|
// add by qiubing
|
||||||
// 获取 Graph
|
// 获取 Graph
|
||||||
func GetGraph(ctx *context.APIContext) {
|
func GetGraph(ctx *context.APIContext) {
|
||||||
|
|
||||||
if ctx.Repo.Repository.IsEmpty { // 项目是否为空
|
if ctx.Repo.Repository.IsEmpty { // 项目是否为空
|
||||||
ctx.JSON(409, api.APIError{
|
ctx.JSON(http.StatusConflict, api.APIError{
|
||||||
Message: "Git Repository is empty.",
|
Message: "Git Repository is empty.",
|
||||||
URL: setting.API.SwaggerURL,
|
URL: setting.API.SwaggerURL,
|
||||||
})
|
})
|
||||||
|
@ -334,7 +637,7 @@ func GetGraph(ctx *context.APIContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(200, &graph)
|
ctx.JSON(http.StatusOK, &graph)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取 commit diff
|
// 获取 commit diff
|
||||||
|
@ -350,7 +653,7 @@ func Diff(ctx *context.APIContext) {
|
||||||
ctx.NotFound("GetDiffCommit", err)
|
ctx.NotFound("GetDiffCommit", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.JSON(200, &diff)
|
ctx.JSON(http.StatusOK, &diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取文件 blame 信息
|
// 获取文件 blame 信息
|
||||||
|
@ -415,7 +718,7 @@ func GetCommitsCount(ctx *context.APIContext) {
|
||||||
ctx.ServerError("GetCommitsCount", err)
|
ctx.ServerError("GetCommitsCount", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.JSON(200, &ctx.Repo)
|
ctx.JSON(http.StatusOK, &ctx.Repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// end by qiubing
|
// end by qiubing
|
||||||
|
|
|
@ -57,6 +57,11 @@ func GetRawFile(ctx *context.APIContext) {
|
||||||
// description: filepath of the file to get
|
// description: filepath of the file to get
|
||||||
// type: string
|
// type: string
|
||||||
// required: true
|
// required: true
|
||||||
|
// - name: ref
|
||||||
|
// in: query
|
||||||
|
// description: "The name of the commit/branch/tag. Default the repository’s default branch (usually master)"
|
||||||
|
// type: string
|
||||||
|
// required: false
|
||||||
// responses:
|
// responses:
|
||||||
// 200:
|
// 200:
|
||||||
// description: success
|
// description: success
|
||||||
|
@ -68,7 +73,14 @@ func GetRawFile(ctx *context.APIContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath)
|
ref := ctx.QueryTrim("ref")
|
||||||
|
|
||||||
|
commit, err := ctx.Repo.GitRepo.GetCommit(ref)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
blob, err := commit.GetBlobByPath(ctx.Repo.TreePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if git.IsErrNotExist(err) {
|
if git.IsErrNotExist(err) {
|
||||||
ctx.NotFound()
|
ctx.NotFound()
|
||||||
|
@ -528,7 +540,6 @@ func GetContents(ctx *context.APIContext) {
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
if !canReadFiles(ctx.Repo) {
|
if !canReadFiles(ctx.Repo) {
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/convert"
|
"code.gitea.io/gitea/modules/convert"
|
||||||
|
@ -56,6 +59,22 @@ func ListTags(ctx *context.APIContext) {
|
||||||
apiTags[i] = convert.ToTag(ctx.Repo.Repository, tags[i])
|
apiTags[i] = convert.ToTag(ctx.Repo.Repository, tags[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tagsCountTotal, err := ctx.Repo.GitRepo.GetTagCount()
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, "GetTagCount", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pageCount := int(math.Ceil(float64(tagsCountTotal) / float64(listOpts.PageSize)))
|
||||||
|
ctx.Header().Set("X-Page", strconv.Itoa(listOpts.Page))
|
||||||
|
ctx.Header().Set("X-PerPage", strconv.Itoa(listOpts.PageSize))
|
||||||
|
ctx.Header().Set("X-Total", strconv.FormatInt(tagsCountTotal, 10))
|
||||||
|
ctx.Header().Set("X-PageCount", strconv.Itoa(pageCount))
|
||||||
|
ctx.Header().Set("X-HasMore", strconv.FormatBool(listOpts.Page < pageCount))
|
||||||
|
|
||||||
|
ctx.SetLinkHeader(int(tagsCountTotal), listOpts.PageSize)
|
||||||
|
ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", tagsCountTotal))
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, &apiTags)
|
ctx.JSON(http.StatusOK, &apiTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,6 +339,11 @@ func EditWiki(ctx *context.APIContext, form api.WikiOption) {
|
||||||
}
|
}
|
||||||
wikiRepo, commit, _ := wikies.FindWikiRepoCommit(ctx)
|
wikiRepo, commit, _ := wikies.FindWikiRepoCommit(ctx)
|
||||||
|
|
||||||
|
if _, _, _, noEntry := wikies.WikiContentsByName(ctx, commit, oldWikiName); noEntry {
|
||||||
|
ctx.Error(http.StatusNotFound, "WikiNotFound", "wiki不存在")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if _, _, _, noEntry := wikies.WikiContentsByName(ctx, commit, newWikiName); oldWikiName != newWikiName && !noEntry {
|
if _, _, _, noEntry := wikies.WikiContentsByName(ctx, commit, newWikiName); oldWikiName != newWikiName && !noEntry {
|
||||||
ctx.Error(http.StatusConflict, "WikiNameAlreadyExist", "wiki名称已存在")
|
ctx.Error(http.StatusConflict, "WikiNameAlreadyExist", "wiki名称已存在")
|
||||||
return
|
return
|
||||||
|
@ -352,7 +357,8 @@ func EditWiki(ctx *context.APIContext, form api.WikiOption) {
|
||||||
ctx.Error(http.StatusInternalServerError, "EditWikiPage", err)
|
ctx.Error(http.StatusInternalServerError, "EditWikiPage", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, entry, pageFilename, _ := wikies.WikiContentsByName(ctx, commit, form.Name)
|
_, newCommit, _ := wikies.FindWikiRepoCommit(ctx)
|
||||||
|
data, entry, pageFilename, _ := wikies.WikiContentsByName(ctx, newCommit, newWikiName)
|
||||||
c, err := wikiRepo.GetCommitByPath(entry.Name())
|
c, err := wikiRepo.GetCommitByPath(entry.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if models.IsErrWikiInvalidFileName(err) {
|
if models.IsErrWikiInvalidFileName(err) {
|
||||||
|
|
|
@ -53,6 +53,21 @@ type swaggerResponseBranchProtectionList struct {
|
||||||
// TagList
|
// TagList
|
||||||
// swagger:response TagList
|
// swagger:response TagList
|
||||||
type swaggerResponseTagList struct {
|
type swaggerResponseTagList struct {
|
||||||
|
// The current page
|
||||||
|
Page int `json:"X-Page"`
|
||||||
|
|
||||||
|
// Commits per page
|
||||||
|
PerPage int `json:"X-PerPage"`
|
||||||
|
|
||||||
|
// Total commit count
|
||||||
|
Total int `json:"X-Total"`
|
||||||
|
|
||||||
|
// Total number of pages
|
||||||
|
PageCount int `json:"X-PageCount"`
|
||||||
|
|
||||||
|
// True if there is another page
|
||||||
|
HasMore bool `json:"X-HasMore"`
|
||||||
|
|
||||||
// in:body
|
// in:body
|
||||||
Body []api.Tag `json:"body"`
|
Body []api.Tag `json:"body"`
|
||||||
}
|
}
|
||||||
|
@ -275,6 +290,28 @@ type swaggerCommitList struct {
|
||||||
Body []api.Commit `json:"body"`
|
Body []api.Commit `json:"body"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FileCommitList
|
||||||
|
// swagger:response FileCommitList
|
||||||
|
type swaggerFileCommitList struct {
|
||||||
|
// The current page
|
||||||
|
Page int `json:"X-Page"`
|
||||||
|
|
||||||
|
// Commits per page
|
||||||
|
PerPage int `json:"X-PerPage"`
|
||||||
|
|
||||||
|
// Total commit count
|
||||||
|
Total int `json:"X-Total"`
|
||||||
|
|
||||||
|
// Total number of pages
|
||||||
|
PageCount int `json:"X-PageCount"`
|
||||||
|
|
||||||
|
// True if there is another page
|
||||||
|
HasMore bool `json:"X-HasMore"`
|
||||||
|
|
||||||
|
// in: body
|
||||||
|
Body []api.Commit `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
// EmptyRepository
|
// EmptyRepository
|
||||||
// swagger:response EmptyRepository
|
// swagger:response EmptyRepository
|
||||||
type swaggerEmptyRepository struct {
|
type swaggerEmptyRepository struct {
|
||||||
|
|
|
@ -2,6 +2,17 @@ package viewfile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
|
gotemplate "html/template"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/charset"
|
"code.gitea.io/gitea/modules/charset"
|
||||||
|
@ -13,17 +24,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/repofiles"
|
"code.gitea.io/gitea/modules/repofiles"
|
||||||
repo_module "code.gitea.io/gitea/modules/repository"
|
repo_module "code.gitea.io/gitea/modules/repository"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"encoding/base64"
|
|
||||||
"fmt"
|
|
||||||
"gitea.com/macaron/macaron"
|
"gitea.com/macaron/macaron"
|
||||||
gotemplate "html/template"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"path"
|
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Map2DTO(ctx *context.APIContext) (dto *ReadmeDTO) {
|
func Map2DTO(ctx *context.APIContext) (dto *ReadmeDTO) {
|
||||||
|
@ -38,7 +39,6 @@ func Map2DTO(ctx *context.APIContext) (dto *ReadmeDTO) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// RepoRefByType handles repository reference name for a specific type
|
// RepoRefByType handles repository reference name for a specific type
|
||||||
// of repository reference
|
// of repository reference
|
||||||
func RepoRefByType(refType context.RepoRefType) macaron.Handler {
|
func RepoRefByType(refType context.RepoRefType) macaron.Handler {
|
||||||
|
@ -162,7 +162,6 @@ func RepoRefByType(refType context.RepoRefType) macaron.Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func getRefName(ctx *context.APIContext, pathType context.RepoRefType) string {
|
func getRefName(ctx *context.APIContext, pathType context.RepoRefType) string {
|
||||||
path := ctx.Params("*")
|
path := ctx.Params("*")
|
||||||
switch pathType {
|
switch pathType {
|
||||||
|
@ -223,8 +222,6 @@ func GetRefType() macaron.Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func CommitCount(ctx *context.APIContext) {
|
func CommitCount(ctx *context.APIContext) {
|
||||||
// swagger:operation GET /repos/{owner}/{repo}/count repository Count
|
// swagger:operation GET /repos/{owner}/{repo}/count repository Count
|
||||||
// ---
|
// ---
|
||||||
|
@ -253,7 +250,6 @@ func CommitCount(ctx *context.APIContext) {
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
|
|
||||||
ref := ctx.QueryTrim("ref")
|
ref := ctx.QueryTrim("ref")
|
||||||
if ref == "" {
|
if ref == "" {
|
||||||
ref = ctx.Params(":ref")
|
ref = ctx.Params(":ref")
|
||||||
|
@ -281,7 +277,6 @@ func CommitCount(ctx *context.APIContext) {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get the commit object for the ref
|
// Get the commit object for the ref
|
||||||
commit, err := ctx.Repo.GitRepo.GetCommit(ref)
|
commit, err := ctx.Repo.GitRepo.GetCommit(ref)
|
||||||
if err != nil || commit == nil {
|
if err != nil || commit == nil {
|
||||||
|
@ -331,7 +326,6 @@ func CommitCount(ctx *context.APIContext) {
|
||||||
ctx.JSON(http.StatusOK, dto)
|
ctx.JSON(http.StatusOK, dto)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type CountDTO struct {
|
type CountDTO struct {
|
||||||
Branch struct {
|
Branch struct {
|
||||||
CommitCount int64 `json:"commit_count"`
|
CommitCount int64 `json:"commit_count"`
|
||||||
|
@ -383,7 +377,6 @@ func LatestRelease(ctx *context.APIContext) {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
release, err := models.GetLatestReleaseByRepoIDExt(ctx.Repo.Repository.ID)
|
release, err := models.GetLatestReleaseByRepoIDExt(ctx.Repo.Repository.ID)
|
||||||
//fmt.Println("****************ctx.Repo.Repository.ID:",ctx.Repo.Repository.ID," ",release," ",err)
|
//fmt.Println("****************ctx.Repo.Repository.ID:",ctx.Repo.Repository.ID," ",release," ",err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -404,7 +397,6 @@ func LatestRelease(ctx *context.APIContext) {
|
||||||
ctx.JSON(http.StatusOK, release)
|
ctx.JSON(http.StatusOK, release)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func Readme(ctx *context.APIContext) {
|
func Readme(ctx *context.APIContext) {
|
||||||
// swagger:operation GET /repos/{owner}/{repo}/readme repository readme
|
// swagger:operation GET /repos/{owner}/{repo}/readme repository readme
|
||||||
// ---
|
// ---
|
||||||
|
@ -512,7 +504,6 @@ func Readme(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ctx.Data["Paths"] = paths
|
ctx.Data["Paths"] = paths
|
||||||
ctx.Data["TreeLink"] = treeLink
|
ctx.Data["TreeLink"] = treeLink
|
||||||
ctx.Data["TreeNames"] = treeNames
|
ctx.Data["TreeNames"] = treeNames
|
||||||
|
@ -528,6 +519,78 @@ func Readme(ctx *context.APIContext) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////
|
||||||
|
func ReadmeByPath(ctx *context.APIContext) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/readme/{dir} repository readmePathContents
|
||||||
|
// ---
|
||||||
|
// summary: Gets the metadata and contents (if a file) of an entry in a repository, or a list of entries if a dir
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: dir
|
||||||
|
// in: path
|
||||||
|
// description: name of the path
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: ref
|
||||||
|
// in: query
|
||||||
|
// description: "The name of the commit/branch/tag. Default the repository’s default branch (usually master)"
|
||||||
|
// type: string
|
||||||
|
// required: false
|
||||||
|
// responses:
|
||||||
|
// "200":
|
||||||
|
// "$ref": "#/responses/ContentsResponse"
|
||||||
|
// "404":
|
||||||
|
// "$ref": "#/responses/notFound"
|
||||||
|
|
||||||
|
treePath := ctx.Params("*")
|
||||||
|
ref := ctx.QueryTrim("ref")
|
||||||
|
if ref == "" {
|
||||||
|
ref = ctx.Params(":ref")
|
||||||
|
if ref == "" {
|
||||||
|
ref = ctx.Repo.Repository.DefaultBranch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
namedBlob, err := getReadmeFileFromPathExt(ctx, treePath, ref)
|
||||||
|
if err != nil || namedBlob == nil {
|
||||||
|
// ctx.NotFound("getReadmeFileFromPath", err)
|
||||||
|
fileList, err1 := repofiles.GetContentsOrList(ctx.Repo.Repository, treePath, ref)
|
||||||
|
if err1 != nil {
|
||||||
|
if git.IsErrNotExist(err1) {
|
||||||
|
ctx.NotFound("fileList", err1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.Error(http.StatusInternalServerError, "GetFileListByPath", err)
|
||||||
|
} else {
|
||||||
|
ctx.JSON(http.StatusOK, fileList)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FoundFileItem := namedBlob.name
|
||||||
|
newTreePath := treePath + "/" + FoundFileItem
|
||||||
|
|
||||||
|
contents, err2 := repofiles.GetContents(ctx.Repo.Repository, newTreePath, ref, false)
|
||||||
|
if err2 != nil {
|
||||||
|
if git.IsErrNotExist(err2) {
|
||||||
|
ctx.NotFound("GetReadmeContentByPath", err2)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ctx.Error(http.StatusInternalServerError, "GetReadmeContentByPath", err)
|
||||||
|
} else {
|
||||||
|
ctx.JSON(http.StatusOK, contents)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func ViewFile(ctx *context.APIContext) {
|
func ViewFile(ctx *context.APIContext) {
|
||||||
ctx.Data["Encoding"] = "base64"
|
ctx.Data["Encoding"] = "base64"
|
||||||
|
@ -606,7 +669,6 @@ func ViewFile(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ctx.Data["Paths"] = paths
|
ctx.Data["Paths"] = paths
|
||||||
ctx.Data["TreeLink"] = treeLink
|
ctx.Data["TreeLink"] = treeLink
|
||||||
ctx.Data["TreeNames"] = treeNames
|
ctx.Data["TreeNames"] = treeNames
|
||||||
|
@ -798,7 +860,6 @@ func safeURL(address string) string {
|
||||||
return u.String()
|
return u.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func linesBytesCount(s []byte) int {
|
func linesBytesCount(s []byte) int {
|
||||||
nl := []byte{'\n'}
|
nl := []byte{'\n'}
|
||||||
n := bytes.Count(s, nl)
|
n := bytes.Count(s, nl)
|
||||||
|
@ -820,7 +881,6 @@ func linesBytesCount(s []byte) int {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// FIXME: There has to be a more efficient way of doing this
|
// FIXME: There has to be a more efficient way of doing this
|
||||||
func getReadmeFileFromPath(commit *git.Commit, treePath string) (*namedBlob, error) {
|
func getReadmeFileFromPath(commit *git.Commit, treePath string) (*namedBlob, error) {
|
||||||
|
|
||||||
|
@ -914,7 +974,6 @@ func getReadmeFileFromPathExt(ctx *context.APIContext, treePath, ref string) (*n
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get the commit object for the ref
|
// Get the commit object for the ref
|
||||||
commit, err := ctx.Repo.GitRepo.GetCommit(ref)
|
commit, err := ctx.Repo.GitRepo.GetCommit(ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -995,7 +1054,6 @@ func getReadmeFileFromPathExt(ctx *context.APIContext, treePath, ref string) (*n
|
||||||
return readmeFile, nil
|
return readmeFile, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func FindFiles(ctx *context.APIContext) {
|
func FindFiles(ctx *context.APIContext) {
|
||||||
// swagger:operation GET /repos/{owner}/{repo}/find repository find
|
// swagger:operation GET /repos/{owner}/{repo}/find repository find
|
||||||
// ---
|
// ---
|
||||||
|
@ -1067,14 +1125,12 @@ func FindFileFromPathExt(ctx *context.APIContext, treePath, ref, key string) (fi
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get the commit object for the ref
|
// Get the commit object for the ref
|
||||||
commit, err := ctx.Repo.GitRepo.GetCommit(ref)
|
commit, err := ctx.Repo.GitRepo.GetCommit(ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tree, err := commit.SubTree(treePath)
|
tree, err := commit.SubTree(treePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1096,7 +1152,6 @@ func FindFileFromPathExt(ctx *context.APIContext, treePath, ref, key string) (fi
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fileName := filepath.Base(entry.Name())
|
fileName := filepath.Base(entry.Name())
|
||||||
|
|
||||||
if strings.Contains(strings.ToLower(fileName), strings.ToLower(key)) || key == "" {
|
if strings.Contains(strings.ToLower(fileName), strings.ToLower(key)) || key == "" {
|
||||||
|
@ -1129,7 +1184,6 @@ func FindFileFromPathExt(ctx *context.APIContext, treePath, ref, key string) (fi
|
||||||
}
|
}
|
||||||
htmlURLString := htmlURL.String()
|
htmlURLString := htmlURL.String()
|
||||||
|
|
||||||
|
|
||||||
Item := &SearchFileItem{
|
Item := &SearchFileItem{
|
||||||
Name: fileName,
|
Name: fileName,
|
||||||
Path: treePath,
|
Path: treePath,
|
||||||
|
@ -1159,7 +1213,6 @@ func FindFileFromPathExt(ctx *context.APIContext, treePath, ref, key string) (fi
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type SearchFileItem struct {
|
type SearchFileItem struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
@ -1189,7 +1242,6 @@ func IsReadmeFileExt(name string, ext ...string) bool {
|
||||||
return name[:7] == "readme_zh."
|
return name[:7] == "readme_zh."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type namedBlob struct {
|
type namedBlob struct {
|
||||||
name string
|
name string
|
||||||
isSymlink bool
|
isSymlink bool
|
||||||
|
|
|
@ -179,7 +179,7 @@ func FileHistory(ctx *context.Context) {
|
||||||
page = 1
|
page = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page)
|
commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(branchName, fileName, page, 50)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("CommitsByFileAndRange", err)
|
ctx.ServerError("CommitsByFileAndRange", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -277,7 +277,7 @@ func renderRevisionPage(ctx *context.Context) (*git.Repository, *git.TreeEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get Commit Count
|
// get Commit Count
|
||||||
commitsHistory, err := wikiRepo.CommitsByFileAndRangeNoFollow("master", pageFilename, page)
|
commitsHistory, err := wikiRepo.CommitsByFileAndRangeNoFollow("master", pageFilename, page, 50)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if wikiRepo != nil {
|
if wikiRepo != nil {
|
||||||
wikiRepo.Close()
|
wikiRepo.Close()
|
||||||
|
|
|
@ -2443,6 +2443,39 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/repos/{owner}/{repo}/branches/branches_slice": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"repository"
|
||||||
|
],
|
||||||
|
"summary": "List a repository's branches, Group sort.",
|
||||||
|
"operationId": "repoListBranchesSlice",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "owner of the repo",
|
||||||
|
"name": "owner",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the repo",
|
||||||
|
"name": "repo",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"$ref": "#/responses/BranchList"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/repos/{owner}/{repo}/branches/{branch}": {
|
"/repos/{owner}/{repo}/branches/{branch}": {
|
||||||
"get": {
|
"get": {
|
||||||
"produces": [
|
"produces": [
|
||||||
|
@ -2810,6 +2843,63 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/repos/{owner}/{repo}/commits_slice": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"repository"
|
||||||
|
],
|
||||||
|
"summary": "Get a list of all commits from a repository",
|
||||||
|
"operationId": "repoGetAllCommitsSlice",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "owner of the repo",
|
||||||
|
"name": "owner",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the repo",
|
||||||
|
"name": "repo",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SHA or branch to start listing commits from (usually 'master')",
|
||||||
|
"name": "sha",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "page number of results to return (1-based)",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "page size of results",
|
||||||
|
"name": "limit",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"$ref": "#/responses/CommitList"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"$ref": "#/responses/notFound"
|
||||||
|
},
|
||||||
|
"409": {
|
||||||
|
"$ref": "#/responses/EmptyRepository"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/repos/{owner}/{repo}/contents": {
|
"/repos/{owner}/{repo}/contents": {
|
||||||
"get": {
|
"get": {
|
||||||
"produces": [
|
"produces": [
|
||||||
|
@ -3196,6 +3286,70 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/repos/{owner}/{repo}/file_commits/{filepath}": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"repository"
|
||||||
|
],
|
||||||
|
"summary": "Get a list of all commits by filepath from a repository",
|
||||||
|
"operationId": "repoGetFileAllCommits",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "owner of the repo",
|
||||||
|
"name": "owner",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the repo",
|
||||||
|
"name": "repo",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "filepath of the file to get",
|
||||||
|
"name": "filepath",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SHA or branch to start listing commits from (usually 'master')",
|
||||||
|
"name": "sha",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "page number of results to return (1-based)",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "page size of results",
|
||||||
|
"name": "limit",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"$ref": "#/responses/FileCommitList"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"$ref": "#/responses/notFound"
|
||||||
|
},
|
||||||
|
"409": {
|
||||||
|
"$ref": "#/responses/EmptyRepository"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/repos/{owner}/{repo}/find": {
|
"/repos/{owner}/{repo}/find": {
|
||||||
"get": {
|
"get": {
|
||||||
"produces": [
|
"produces": [
|
||||||
|
@ -7609,6 +7763,12 @@
|
||||||
"name": "filepath",
|
"name": "filepath",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)",
|
||||||
|
"name": "ref",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
@ -7663,6 +7823,55 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/repos/{owner}/{repo}/readme/{dir}": {
|
||||||
|
"get": {
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"repository"
|
||||||
|
],
|
||||||
|
"summary": "Gets the metadata and contents (if a file) of an entry in a repository, or a list of entries if a dir",
|
||||||
|
"operationId": "readmePathContents",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "owner of the repo",
|
||||||
|
"name": "owner",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the repo",
|
||||||
|
"name": "repo",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the path",
|
||||||
|
"name": "dir",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "The name of the commit/branch/tag. Default the repository’s default branch (usually master)",
|
||||||
|
"name": "ref",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"$ref": "#/responses/ContentsResponse"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"$ref": "#/responses/notFound"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/repos/{owner}/{repo}/releases": {
|
"/repos/{owner}/{repo}/releases": {
|
||||||
"get": {
|
"get": {
|
||||||
"produces": [
|
"produces": [
|
||||||
|
@ -11303,9 +11512,26 @@
|
||||||
"description": "Branch represents a repository branch",
|
"description": "Branch represents a repository branch",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"branch_kind": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"x-go-name": "BranchKind"
|
||||||
|
},
|
||||||
"commit": {
|
"commit": {
|
||||||
"$ref": "#/definitions/PayloadCommit"
|
"$ref": "#/definitions/PayloadCommit"
|
||||||
},
|
},
|
||||||
|
"commit_id": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "CommitID"
|
||||||
|
},
|
||||||
|
"commit_time": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "CommitTime"
|
||||||
|
},
|
||||||
|
"default_branch": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "DefaultBranch"
|
||||||
|
},
|
||||||
"effective_branch_protection_name": {
|
"effective_branch_protection_name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "EffectiveBranchProtectionName"
|
"x-go-name": "EffectiveBranchProtectionName"
|
||||||
|
@ -11530,14 +11756,21 @@
|
||||||
},
|
},
|
||||||
"Commit": {
|
"Commit": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Commit contains information generated from a Git commit.",
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"author": {
|
"author": {
|
||||||
"$ref": "#/definitions/User"
|
"$ref": "#/definitions/User"
|
||||||
},
|
},
|
||||||
|
"branch": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Branch"
|
||||||
|
},
|
||||||
"commit": {
|
"commit": {
|
||||||
"$ref": "#/definitions/RepoCommit"
|
"$ref": "#/definitions/RepoCommit"
|
||||||
},
|
},
|
||||||
|
"commit_date": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "CommitDate"
|
||||||
|
},
|
||||||
"committer": {
|
"committer": {
|
||||||
"$ref": "#/definitions/User"
|
"$ref": "#/definitions/User"
|
||||||
},
|
},
|
||||||
|
@ -14773,6 +15006,10 @@
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
"x-go-name": "PublishedAt"
|
"x-go-name": "PublishedAt"
|
||||||
},
|
},
|
||||||
|
"sha": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Sha1"
|
||||||
|
},
|
||||||
"tag_name": {
|
"tag_name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "TagName"
|
"x-go-name": "TagName"
|
||||||
|
@ -15158,16 +15395,23 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"commit": {
|
"commit": {
|
||||||
"$ref": "#/definitions/CommitMeta"
|
"$ref": "#/definitions/TagCommit"
|
||||||
},
|
},
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "ID"
|
"x-go-name": "ID"
|
||||||
},
|
},
|
||||||
|
"message": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Message"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Name"
|
"x-go-name": "Name"
|
||||||
},
|
},
|
||||||
|
"tagger": {
|
||||||
|
"$ref": "#/definitions/CommitUser"
|
||||||
|
},
|
||||||
"tarball_url": {
|
"tarball_url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "TarballURL"
|
"x-go-name": "TarballURL"
|
||||||
|
@ -15179,6 +15423,30 @@
|
||||||
},
|
},
|
||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
},
|
},
|
||||||
|
"TagCommit": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"author": {
|
||||||
|
"$ref": "#/definitions/CommitUser"
|
||||||
|
},
|
||||||
|
"commiter": {
|
||||||
|
"$ref": "#/definitions/CommitUser"
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Message"
|
||||||
|
},
|
||||||
|
"sha": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "SHA"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "URL"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
|
},
|
||||||
"Team": {
|
"Team": {
|
||||||
"description": "Team represents a team in an organization",
|
"description": "Team represents a team in an organization",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -15783,6 +16051,41 @@
|
||||||
"$ref": "#/definitions/APIError"
|
"$ref": "#/definitions/APIError"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"FileCommitList": {
|
||||||
|
"description": "FileCommitList",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/Commit"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"X-HasMore": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "True if there is another page"
|
||||||
|
},
|
||||||
|
"X-Page": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "The current page"
|
||||||
|
},
|
||||||
|
"X-PageCount": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "Total number of pages"
|
||||||
|
},
|
||||||
|
"X-PerPage": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "Commits per page"
|
||||||
|
},
|
||||||
|
"X-Total": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "Total commit count"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"FileDeleteResponse": {
|
"FileDeleteResponse": {
|
||||||
"description": "FileDeleteResponse",
|
"description": "FileDeleteResponse",
|
||||||
"schema": {
|
"schema": {
|
||||||
|
@ -16175,6 +16478,32 @@
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/Tag"
|
"$ref": "#/definitions/Tag"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"X-HasMore": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "True if there is another page"
|
||||||
|
},
|
||||||
|
"X-Page": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "The current page"
|
||||||
|
},
|
||||||
|
"X-PageCount": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "Total number of pages"
|
||||||
|
},
|
||||||
|
"X-PerPage": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "Commits per page"
|
||||||
|
},
|
||||||
|
"X-Total": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "Total commit count"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Team": {
|
"Team": {
|
||||||
|
|
Loading…
Reference in New Issue