@ -70,6 +70,7 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
// responses:
// responses:
// "200":
// "200":
// "$ref": "#/responses/PullRequestList"
// "$ref": "#/responses/PullRequestList"
prs , maxResults , err := models . PullRequests ( ctx . Repo . Repository . ID , & models . PullRequestsOptions {
prs , maxResults , err := models . PullRequests ( ctx . Repo . Repository . ID , & models . PullRequestsOptions {
Page : ctx . QueryInt ( "page" ) ,
Page : ctx . QueryInt ( "page" ) ,
State : ctx . QueryTrim ( "state" ) ,
State : ctx . QueryTrim ( "state" ) ,
@ -79,33 +80,33 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
} )
} )
if err != nil {
if err != nil {
ctx . Error ( 500 , "PullRequests" , err )
ctx . Error ( http . StatusInternalServerError , "PullRequests" , err )
return
return
}
}
apiPrs := make ( [ ] * api . PullRequest , len ( prs ) )
apiPrs := make ( [ ] * api . PullRequest , len ( prs ) )
for i := range prs {
for i := range prs {
if err = prs [ i ] . LoadIssue ( ) ; err != nil {
if err = prs [ i ] . LoadIssue ( ) ; err != nil {
ctx . Error ( 500 , "LoadIssue" , err )
ctx . Error ( http . StatusInternalServerError , "LoadIssue" , err )
return
return
}
}
if err = prs [ i ] . LoadAttributes ( ) ; err != nil {
if err = prs [ i ] . LoadAttributes ( ) ; err != nil {
ctx . Error ( 500 , "LoadAttributes" , err )
ctx . Error ( http . StatusInternalServerError , "LoadAttributes" , err )
return
return
}
}
if err = prs [ i ] . GetBaseRepo ( ) ; err != nil {
if err = prs [ i ] . GetBaseRepo ( ) ; err != nil {
ctx . Error ( 500 , "GetBaseRepo" , err )
ctx . Error ( http . StatusInternalServerError , "GetBaseRepo" , err )
return
return
}
}
if err = prs [ i ] . GetHeadRepo ( ) ; err != nil {
if err = prs [ i ] . GetHeadRepo ( ) ; err != nil {
ctx . Error ( 500 , "GetHeadRepo" , err )
ctx . Error ( http . StatusInternalServerError , "GetHeadRepo" , err )
return
return
}
}
apiPrs [ i ] = prs [ i ] . APIFormat ( )
apiPrs [ i ] = prs [ i ] . APIFormat ( )
}
}
ctx . SetLinkHeader ( int ( maxResults ) , models . ItemsPerPage )
ctx . SetLinkHeader ( int ( maxResults ) , models . ItemsPerPage )
ctx . JSON ( 200 , & apiPrs )
ctx . JSON ( http . StatusOK , & apiPrs )
}
}
// GetPullRequest returns a single PR based on index
// GetPullRequest returns a single PR based on index
@ -135,25 +136,26 @@ func GetPullRequest(ctx *context.APIContext) {
// responses:
// responses:
// "200":
// "200":
// "$ref": "#/responses/PullRequest"
// "$ref": "#/responses/PullRequest"
pr , err := models . GetPullRequestByIndex ( ctx . Repo . Repository . ID , ctx . ParamsInt64 ( ":index" ) )
pr , err := models . GetPullRequestByIndex ( ctx . Repo . Repository . ID , ctx . ParamsInt64 ( ":index" ) )
if err != nil {
if err != nil {
if models . IsErrPullRequestNotExist ( err ) {
if models . IsErrPullRequestNotExist ( err ) {
ctx . NotFound ( )
ctx . NotFound ( )
} else {
} else {
ctx . Error ( 500 , "GetPullRequestByIndex" , err )
ctx . Error ( http . StatusInternalServerError , "GetPullRequestByIndex" , err )
}
}
return
return
}
}
if err = pr . GetBaseRepo ( ) ; err != nil {
if err = pr . GetBaseRepo ( ) ; err != nil {
ctx . Error ( 500 , "GetBaseRepo" , err )
ctx . Error ( http . StatusInternalServerError , "GetBaseRepo" , err )
return
return
}
}
if err = pr . GetHeadRepo ( ) ; err != nil {
if err = pr . GetHeadRepo ( ) ; err != nil {
ctx . Error ( 500 , "GetHeadRepo" , err )
ctx . Error ( http . StatusInternalServerError , "GetHeadRepo" , err )
return
return
}
}
ctx . JSON ( 200 , pr . APIFormat ( ) )
ctx . JSON ( http . StatusOK , pr . APIFormat ( ) )
}
}
// CreatePullRequest does what it says
// CreatePullRequest does what it says
@ -183,6 +185,11 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
// responses:
// responses:
// "201":
// "201":
// "$ref": "#/responses/PullRequest"
// "$ref": "#/responses/PullRequest"
// "409":
// "$ref": "#/responses/error"
// "422":
// "$ref": "#/responses/validationError"
var (
var (
repo = ctx . Repo . Repository
repo = ctx . Repo . Repository
labelIDs [ ] int64
labelIDs [ ] int64
@ -201,7 +208,7 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
existingPr , err := models . GetUnmergedPullRequest ( headRepo . ID , ctx . Repo . Repository . ID , headBranch , baseBranch )
existingPr , err := models . GetUnmergedPullRequest ( headRepo . ID , ctx . Repo . Repository . ID , headBranch , baseBranch )
if err != nil {
if err != nil {
if ! models . IsErrPullRequestNotExist ( err ) {
if ! models . IsErrPullRequestNotExist ( err ) {
ctx . Error ( 500 , "GetUnmergedPullRequest" , err )
ctx . Error ( http . StatusInternalServerError , "GetUnmergedPullRequest" , err )
return
return
}
}
} else {
} else {
@ -213,14 +220,14 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
HeadBranch : existingPr . HeadBranch ,
HeadBranch : existingPr . HeadBranch ,
BaseBranch : existingPr . BaseBranch ,
BaseBranch : existingPr . BaseBranch ,
}
}
ctx . Error ( 409 , "GetUnmergedPullRequest" , err )
ctx . Error ( http . StatusConflict , "GetUnmergedPullRequest" , err )
return
return
}
}
if len ( form . Labels ) > 0 {
if len ( form . Labels ) > 0 {
labels , err := models . GetLabelsInRepoByIDs ( ctx . Repo . Repository . ID , form . Labels )
labels , err := models . GetLabelsInRepoByIDs ( ctx . Repo . Repository . ID , form . Labels )
if err != nil {
if err != nil {
ctx . Error ( 500 , "GetLabelsInRepoByIDs" , err )
ctx . Error ( http . StatusInternalServerError , "GetLabelsInRepoByIDs" , err )
return
return
}
}
@ -236,7 +243,7 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
if models . IsErrMilestoneNotExist ( err ) {
if models . IsErrMilestoneNotExist ( err ) {
ctx . NotFound ( )
ctx . NotFound ( )
} else {
} else {
ctx . Error ( 500 , "GetMilestoneByRepoID" , err )
ctx . Error ( http . StatusInternalServerError , "GetMilestoneByRepoID" , err )
}
}
return
return
}
}
@ -275,9 +282,9 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
assigneeIDs , err := models . MakeIDsFromAPIAssigneesToAdd ( form . Assignee , form . Assignees )
assigneeIDs , err := models . MakeIDsFromAPIAssigneesToAdd ( form . Assignee , form . Assignees )
if err != nil {
if err != nil {
if models . IsErrUserNotExist ( err ) {
if models . IsErrUserNotExist ( err ) {
ctx . Error ( 422 , "" , fmt . Sprintf ( "Assignee does not exist: [name: %s]" , err ) )
ctx . Error ( http . StatusUnprocessableEntity , "" , fmt . Sprintf ( "Assignee does not exist: [name: %s]" , err ) )
} else {
} else {
ctx . Error ( 500 , "AddAssigneeByName" , err )
ctx . Error ( http . StatusInternalServerError , "AddAssigneeByName" , err )
}
}
return
return
}
}
@ -285,34 +292,34 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
for _ , aID := range assigneeIDs {
for _ , aID := range assigneeIDs {
assignee , err := models . GetUserByID ( aID )
assignee , err := models . GetUserByID ( aID )
if err != nil {
if err != nil {
ctx . Error ( 500 , "GetUserByID" , err )
ctx . Error ( http . StatusInternalServerError , "GetUserByID" , err )
return
return
}
}
valid , err := models . CanBeAssigned ( assignee , repo , true )
valid , err := models . CanBeAssigned ( assignee , repo , true )
if err != nil {
if err != nil {
ctx . Error ( 500 , "canBeAssigned" , err )
ctx . Error ( http . StatusInternalServerError , "canBeAssigned" , err )
return
return
}
}
if ! valid {
if ! valid {
ctx . Error ( 422 , "canBeAssigned" , models . ErrUserDoesNotHaveAccessToRepo { UserID : aID , RepoName : repo . Name } )
ctx . Error ( http . StatusUnprocessableEntity , "canBeAssigned" , models . ErrUserDoesNotHaveAccessToRepo { UserID : aID , RepoName : repo . Name } )
return
return
}
}
}
}
if err := pull_service . NewPullRequest ( repo , prIssue , labelIDs , [ ] string { } , pr , assigneeIDs ) ; err != nil {
if err := pull_service . NewPullRequest ( repo , prIssue , labelIDs , [ ] string { } , pr , assigneeIDs ) ; err != nil {
if models . IsErrUserDoesNotHaveAccessToRepo ( err ) {
if models . IsErrUserDoesNotHaveAccessToRepo ( err ) {
ctx . Error ( 400 , "UserDoesNotHaveAccessToRepo" , err )
ctx . Error ( http . StatusBadRequest , "UserDoesNotHaveAccessToRepo" , err )
return
return
}
}
ctx . Error ( 500 , "NewPullRequest" , err )
ctx . Error ( http . StatusInternalServerError , "NewPullRequest" , err )
return
return
}
}
notification . NotifyNewPullRequest ( pr )
notification . NotifyNewPullRequest ( pr )
log . Trace ( "Pull request created: %d/%d" , repo . ID , prIssue . ID )
log . Trace ( "Pull request created: %d/%d" , repo . ID , prIssue . ID )
ctx . JSON ( 201 , pr . APIFormat ( ) )
ctx . JSON ( http . StatusCreated , pr . APIFormat ( ) )
}
}
// EditPullRequest does what it says
// EditPullRequest does what it says
@ -348,12 +355,19 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
// responses:
// responses:
// "201":
// "201":
// "$ref": "#/responses/PullRequest"
// "$ref": "#/responses/PullRequest"
// "403":
// "$ref": "#/responses/forbidden"
// "412":
// "$ref": "#/responses/error"
// "422":
// "$ref": "#/responses/validationError"
pr , err := models . GetPullRequestByIndex ( ctx . Repo . Repository . ID , ctx . ParamsInt64 ( ":index" ) )
pr , err := models . GetPullRequestByIndex ( ctx . Repo . Repository . ID , ctx . ParamsInt64 ( ":index" ) )
if err != nil {
if err != nil {
if models . IsErrPullRequestNotExist ( err ) {
if models . IsErrPullRequestNotExist ( err ) {
ctx . NotFound ( )
ctx . NotFound ( )
} else {
} else {
ctx . Error ( 500 , "GetPullRequestByIndex" , err )
ctx . Error ( http . StatusInternalServerError , "GetPullRequestByIndex" , err )
}
}
return
return
}
}
@ -367,7 +381,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
issue . Repo = ctx . Repo . Repository
issue . Repo = ctx . Repo . Repository
if ! issue . IsPoster ( ctx . User . ID ) && ! ctx . Repo . CanWrite ( models . UnitTypePullRequests ) {
if ! issue . IsPoster ( ctx . User . ID ) && ! ctx . Repo . CanWrite ( models . UnitTypePullRequests ) {
ctx . Status ( 403 )
ctx . Status ( http . StatusForbidden )
return
return
}
}
@ -388,7 +402,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
}
}
if err := models . UpdateIssueDeadline ( issue , deadlineUnix , ctx . User ) ; err != nil {
if err := models . UpdateIssueDeadline ( issue , deadlineUnix , ctx . User ) ; err != nil {
ctx . Error ( 500 , "UpdateIssueDeadline" , err )
ctx . Error ( http . StatusInternalServerError , "UpdateIssueDeadline" , err )
return
return
}
}
issue . DeadlineUnix = deadlineUnix
issue . DeadlineUnix = deadlineUnix
@ -406,9 +420,9 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
err = issue_service . UpdateAssignees ( issue , form . Assignee , form . Assignees , ctx . User )
err = issue_service . UpdateAssignees ( issue , form . Assignee , form . Assignees , ctx . User )
if err != nil {
if err != nil {
if models . IsErrUserNotExist ( err ) {
if models . IsErrUserNotExist ( err ) {
ctx . Error ( 422 , "" , fmt . Sprintf ( "Assignee does not exist: [name: %s]" , err ) )
ctx . Error ( http . StatusUnprocessableEntity , "" , fmt . Sprintf ( "Assignee does not exist: [name: %s]" , err ) )
} else {
} else {
ctx . Error ( 500 , "UpdateAssignees" , err )
ctx . Error ( http . StatusInternalServerError , "UpdateAssignees" , err )
}
}
return
return
}
}
@ -419,7 +433,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
oldMilestoneID := issue . MilestoneID
oldMilestoneID := issue . MilestoneID
issue . MilestoneID = form . Milestone
issue . MilestoneID = form . Milestone
if err = issue_service . ChangeMilestoneAssign ( issue , ctx . User , oldMilestoneID ) ; err != nil {
if err = issue_service . ChangeMilestoneAssign ( issue , ctx . User , oldMilestoneID ) ; err != nil {
ctx . Error ( 500 , "ChangeMilestoneAssign" , err )
ctx . Error ( http . StatusInternalServerError , "ChangeMilestoneAssign" , err )
return
return
}
}
}
}
@ -427,17 +441,17 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
if ctx . Repo . CanWrite ( models . UnitTypePullRequests ) && form . Labels != nil {
if ctx . Repo . CanWrite ( models . UnitTypePullRequests ) && form . Labels != nil {
labels , err := models . GetLabelsInRepoByIDs ( ctx . Repo . Repository . ID , form . Labels )
labels , err := models . GetLabelsInRepoByIDs ( ctx . Repo . Repository . ID , form . Labels )
if err != nil {
if err != nil {
ctx . Error ( 500 , "GetLabelsInRepoByIDsError" , err )
ctx . Error ( http . StatusInternalServerError , "GetLabelsInRepoByIDsError" , err )
return
return
}
}
if err = issue . ReplaceLabels ( labels , ctx . User ) ; err != nil {
if err = issue . ReplaceLabels ( labels , ctx . User ) ; err != nil {
ctx . Error ( 500 , "ReplaceLabelsError" , err )
ctx . Error ( http . StatusInternalServerError , "ReplaceLabelsError" , err )
return
return
}
}
}
}
if err = models . UpdateIssue ( issue ) ; err != nil {
if err = models . UpdateIssue ( issue ) ; err != nil {
ctx . Error ( 500 , "UpdateIssue" , err )
ctx . Error ( http . StatusInternalServerError , "UpdateIssue" , err )
return
return
}
}
if form . State != nil {
if form . State != nil {
@ -446,7 +460,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
ctx . Error ( http . StatusPreconditionFailed , "DependenciesLeft" , "cannot close this pull request because it still has open dependencies" )
ctx . Error ( http . StatusPreconditionFailed , "DependenciesLeft" , "cannot close this pull request because it still has open dependencies" )
return
return
}
}
ctx . Error ( 500 , "ChangeStatus" , err )
ctx . Error ( http . StatusInternalServerError , "ChangeStatus" , err )
return
return
}
}
}
}
@ -457,13 +471,13 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
if models . IsErrPullRequestNotExist ( err ) {
if models . IsErrPullRequestNotExist ( err ) {
ctx . NotFound ( )
ctx . NotFound ( )
} else {
} else {
ctx . Error ( 500 , "GetPullRequestByIndex" , err )
ctx . Error ( http . StatusInternalServerError , "GetPullRequestByIndex" , err )
}
}
return
return
}
}
// TODO this should be 200, not 201
// TODO this should be 200, not 201
ctx . JSON ( 201 , pr . APIFormat ( ) )
ctx . JSON ( http . StatusCreated , pr . APIFormat ( ) )
}
}
// IsPullRequestMerged checks if a PR exists given an index
// IsPullRequestMerged checks if a PR exists given an index
@ -495,18 +509,19 @@ func IsPullRequestMerged(ctx *context.APIContext) {
// description: pull request has been merged
// description: pull request has been merged
// "404":
// "404":
// description: pull request has not been merged
// description: pull request has not been merged
pr , err := models . GetPullRequestByIndex ( ctx . Repo . Repository . ID , ctx . ParamsInt64 ( ":index" ) )
pr , err := models . GetPullRequestByIndex ( ctx . Repo . Repository . ID , ctx . ParamsInt64 ( ":index" ) )
if err != nil {
if err != nil {
if models . IsErrPullRequestNotExist ( err ) {
if models . IsErrPullRequestNotExist ( err ) {
ctx . NotFound ( )
ctx . NotFound ( )
} else {
} else {
ctx . Error ( 500 , "GetPullRequestByIndex" , err )
ctx . Error ( http . StatusInternalServerError , "GetPullRequestByIndex" , err )
}
}
return
return
}
}
if pr . HasMerged {
if pr . HasMerged {
ctx . Status ( 204 )
ctx . Status ( http . StatusNoContent )
}
}
ctx . NotFound ( )
ctx . NotFound ( )
}
}
@ -544,12 +559,15 @@ func MergePullRequest(ctx *context.APIContext, form auth.MergePullRequestForm) {
// "$ref": "#/responses/empty"
// "$ref": "#/responses/empty"
// "405":
// "405":
// "$ref": "#/responses/empty"
// "$ref": "#/responses/empty"
// "409":
// "$ref": "#/responses/error"
pr , err := models . GetPullRequestByIndex ( ctx . Repo . Repository . ID , ctx . ParamsInt64 ( ":index" ) )
pr , err := models . GetPullRequestByIndex ( ctx . Repo . Repository . ID , ctx . ParamsInt64 ( ":index" ) )
if err != nil {
if err != nil {
if models . IsErrPullRequestNotExist ( err ) {
if models . IsErrPullRequestNotExist ( err ) {
ctx . NotFound ( "GetPullRequestByIndex" , err )
ctx . NotFound ( "GetPullRequestByIndex" , err )
} else {
} else {
ctx . Error ( 500 , "GetPullRequestByIndex" , err )
ctx . Error ( http . StatusInternalServerError , "GetPullRequestByIndex" , err )
}
}
return
return
}
}
@ -569,7 +587,7 @@ func MergePullRequest(ctx *context.APIContext, form auth.MergePullRequestForm) {
if ctx . IsSigned {
if ctx . IsSigned {
// Update issue-user.
// Update issue-user.
if err = pr . Issue . ReadBy ( ctx . User . ID ) ; err != nil {
if err = pr . Issue . ReadBy ( ctx . User . ID ) ; err != nil {
ctx . Error ( 500 , "ReadBy" , err )
ctx . Error ( http . StatusInternalServerError , "ReadBy" , err )
return
return
}
}
}
}
@ -580,18 +598,18 @@ func MergePullRequest(ctx *context.APIContext, form auth.MergePullRequestForm) {
}
}
if ! pr . CanAutoMerge ( ) || pr . HasMerged || pr . IsWorkInProgress ( ) {
if ! pr . CanAutoMerge ( ) || pr . HasMerged || pr . IsWorkInProgress ( ) {
ctx . Status ( 405 )
ctx . Status ( http . StatusMethodNotAllowed )
return
return
}
}
isPass , err := pull_service . IsPullCommitStatusPass ( pr )
isPass , err := pull_service . IsPullCommitStatusPass ( pr )
if err != nil {
if err != nil {
ctx . Error ( 500 , "IsPullCommitStatusPass" , err )
ctx . Error ( http . StatusInternalServerError , "IsPullCommitStatusPass" , err )
return
return
}
}
if ! isPass && ! ctx . IsUserRepoAdmin ( ) {
if ! isPass && ! ctx . IsUserRepoAdmin ( ) {
ctx . Status ( 405 )
ctx . Status ( http . StatusMethodNotAllowed )
return
return
}
}
@ -616,7 +634,7 @@ func MergePullRequest(ctx *context.APIContext, form auth.MergePullRequestForm) {
if err := pull_service . Merge ( pr , ctx . User , ctx . Repo . GitRepo , models . MergeStyle ( form . Do ) , message ) ; err != nil {
if err := pull_service . Merge ( pr , ctx . User , ctx . Repo . GitRepo , models . MergeStyle ( form . Do ) , message ) ; err != nil {
if models . IsErrInvalidMergeStyle ( err ) {
if models . IsErrInvalidMergeStyle ( err ) {
ctx . Status ( 405 )
ctx . Status ( http . StatusMethodNotAllowed )
return
return
} else if models . IsErrMergeConflicts ( err ) {
} else if models . IsErrMergeConflicts ( err ) {
conflictError := err . ( models . ErrMergeConflicts )
conflictError := err . ( models . ErrMergeConflicts )
@ -628,15 +646,15 @@ func MergePullRequest(ctx *context.APIContext, form auth.MergePullRequestForm) {
conflictError := err . ( models . ErrMergeUnrelatedHistories )
conflictError := err . ( models . ErrMergeUnrelatedHistories )
ctx . JSON ( http . StatusConflict , conflictError )
ctx . JSON ( http . StatusConflict , conflictError )
} else if models . IsErrMergePushOutOfDate ( err ) {
} else if models . IsErrMergePushOutOfDate ( err ) {
ctx . Status ( http . StatusConflict )
ctx . Error ( http . StatusConflict , "Merge" , "merge push out of date" )
return
return
}
}
ctx . Error ( 500 , "Merge" , err )
ctx . Error ( http . StatusInternalServerError , "Merge" , err )
return
return
}
}
log . Trace ( "Pull request merged: %d" , pr . ID )
log . Trace ( "Pull request merged: %d" , pr . ID )
ctx . Status ( 200 )
ctx . Status ( http . StatusOK )
}
}
func parseCompareInfo ( ctx * context . APIContext , form api . CreatePullRequestOption ) ( * models . User , * models . Repository , * git . Repository , * git . CompareInfo , string , string ) {
func parseCompareInfo ( ctx * context . APIContext , form api . CreatePullRequestOption ) ( * models . User , * models . Repository , * git . Repository , * git . CompareInfo , string , string ) {
@ -706,7 +724,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
} else {
} else {
headGitRepo , err = git . OpenRepository ( models . RepoPath ( headUser . Name , headRepo . Name ) )
headGitRepo , err = git . OpenRepository ( models . RepoPath ( headUser . Name , headRepo . Name ) )
if err != nil {
if err != nil {
ctx . Error ( 500 , "OpenRepository" , err )
ctx . Error ( http . StatusInternalServerError , "OpenRepository" , err )
return nil , nil , nil , nil , "" , ""
return nil , nil , nil , nil , "" , ""
}
}
}
}
@ -759,7 +777,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
compareInfo , err := headGitRepo . GetCompareInfo ( models . RepoPath ( baseRepo . Owner . Name , baseRepo . Name ) , baseBranch , headBranch )
compareInfo , err := headGitRepo . GetCompareInfo ( models . RepoPath ( baseRepo . Owner . Name , baseRepo . Name ) , baseBranch , headBranch )
if err != nil {
if err != nil {
headGitRepo . Close ( )
headGitRepo . Close ( )
ctx . Error ( 500 , "GetCompareInfo" , err )
ctx . Error ( http . StatusInternalServerError , "GetCompareInfo" , err )
return nil , nil , nil , nil , "" , ""
return nil , nil , nil , nil , "" , ""
}
}