@@ -14,11 +14,8 @@ import (
1414 "code.gitea.io/gitea/models"
1515 repo_model "code.gitea.io/gitea/models/repo"
1616 "code.gitea.io/gitea/models/unit"
17- user_model "code.gitea.io/gitea/models/user"
1817 "code.gitea.io/gitea/modules/context"
19- "code.gitea.io/gitea/modules/convert"
2018 "code.gitea.io/gitea/modules/git"
21- "code.gitea.io/gitea/modules/setting"
2219 api "code.gitea.io/gitea/modules/structs"
2320 "code.gitea.io/gitea/modules/web"
2421 "code.gitea.io/gitea/routers/common"
@@ -601,88 +598,3 @@ func GetContentsList(ctx *context.APIContext) {
601598 // same as GetContents(), this function is here because swagger fails if path is empty in GetContents() interface
602599 GetContents (ctx )
603600}
604-
605- // GetFileHistory get a file's commit history
606- func GetFileHistory (ctx * context.APIContext ) {
607- // swagger:operation GET /repos/{owner}/{repo}/git/history/{filepath} repository repoGetFileHistory
608- // ---
609- // summary: Get the commit history of a file or directory
610- // produces:
611- // - application/json
612- // parameters:
613- // - name: owner
614- // in: path
615- // description: owner of the repo
616- // type: string
617- // required: true
618- // - name: repo
619- // in: path
620- // description: name of the repo
621- // type: string
622- // required: true
623- // - name: filepath
624- // in: path
625- // description: filepath of the file/directory
626- // type: string
627- // required: true
628- // - name: ref
629- // in: query
630- // description: "The name of the ref (branch/tag). Default the repository’s default branch"
631- // type: string
632- // required: false
633- // - name: page
634- // in: query
635- // description: page number of results to return (1-based)
636- // type: integer
637- // responses:
638- // "200":
639- // "$ref": "#/responses/CommitList"
640- // "404":
641- // "$ref": "#/responses/notFound"
642-
643- if ctx .Repo .Repository .IsEmpty {
644- ctx .NotFound ()
645- return
646- }
647-
648- ref := ctx .FormTrim ("ref" )
649- if len (ref ) < 1 {
650- ref = ctx .Repo .Repository .DefaultBranch
651- }
652-
653- page := ctx .FormInt ("page" )
654- if page <= 1 {
655- page = 1
656- }
657-
658- commitsCount , err := ctx .Repo .GitRepo .FileCommitsCount (ref , ctx .Repo .TreePath )
659- if err != nil {
660- ctx .Error (http .StatusInternalServerError , "FileCommitsCount" , err )
661- return
662- } else if commitsCount == 0 {
663- ctx .NotFound ("FileCommitsCount" , nil )
664- return
665- }
666-
667- commits , err := ctx .Repo .GitRepo .CommitsByFileAndRange (ref , ctx .Repo .TreePath , page )
668- if err != nil {
669- ctx .Error (http .StatusInternalServerError , "CommitsByFileAndRange" , err )
670- return
671- }
672-
673- userCache := make (map [string ]* user_model.User )
674- apiCommits := make ([]* api.Commit , len (commits ))
675- for i , commit := range commits {
676- // Create json struct
677- apiCommits [i ], err = convert .ToCommit (ctx .Repo .Repository , commit , userCache )
678- if err != nil {
679- ctx .Error (http .StatusInternalServerError , "toCommit" , err )
680- return
681- }
682- }
683-
684- ctx .SetLinkHeader (int (commitsCount ), setting .Git .CommitsRangeSize )
685- ctx .SetTotalCountHeader (commitsCount )
686-
687- ctx .JSON (http .StatusOK , & apiCommits )
688- }
0 commit comments