@@ -25,24 +25,24 @@ type Branch struct {
25
25
IsProtected bool
26
26
}
27
27
28
- func loadBranches (c * context.Context ) []* Branch {
29
- rawBranches , err := c .Repo .Repository .GetBranches ()
28
+ func loadBranches (ctx * context.Context ) []* Branch {
29
+ rawBranches , err := ctx .Repo .Repository .GetBranches ()
30
30
if err != nil {
31
- c .Handle (500 , "GetBranches" , err )
31
+ ctx .Handle (500 , "GetBranches" , err )
32
32
return nil
33
33
}
34
34
35
- protectBranches , err := c .Repo .Repository .GetProtectedBranches ()
35
+ protectBranches , err := ctx .Repo .Repository .GetProtectedBranches ()
36
36
if err != nil {
37
- c .Handle (500 , "GetProtectBranchesByRepoID " , err )
37
+ ctx .Handle (500 , "GetProtectedBranches " , err )
38
38
return nil
39
39
}
40
40
41
41
branches := make ([]* Branch , len (rawBranches ))
42
42
for i := range rawBranches {
43
43
commit , err := rawBranches [i ].GetCommit ()
44
44
if err != nil {
45
- c .Handle (500 , "GetCommit" , err )
45
+ ctx .Handle (500 , "GetCommit" , err )
46
46
return nil
47
47
}
48
48
@@ -59,17 +59,17 @@ func loadBranches(c *context.Context) []*Branch {
59
59
}
60
60
}
61
61
62
- c .Data ["AllowPullRequest" ] = c .Repo .Repository .AllowsPulls ()
62
+ ctx .Data ["AllowPullRequest" ] = ctx .Repo .Repository .AllowsPulls ()
63
63
return branches
64
64
}
65
65
66
66
// Branches render repository branch page
67
- func Branches (c * context.Context ) {
68
- c .Data ["Title" ] = c .Tr ("repo.git_branches" )
69
- c .Data ["PageIsBranchesOverview" ] = true
67
+ func Branches (ctx * context.Context ) {
68
+ ctx .Data ["Title" ] = ctx .Tr ("repo.git_branches" )
69
+ ctx .Data ["PageIsBranchesOverview" ] = true
70
70
71
- branches := loadBranches (c )
72
- if c .Written () {
71
+ branches := loadBranches (ctx )
72
+ if ctx .Written () {
73
73
return
74
74
}
75
75
@@ -78,64 +78,64 @@ func Branches(c *context.Context) {
78
78
staleBranches := make ([]* Branch , 0 , 3 )
79
79
for i := range branches {
80
80
switch {
81
- case branches [i ].Name == c .Repo .BranchName :
82
- c .Data ["DefaultBranch" ] = branches [i ]
81
+ case branches [i ].Name == ctx .Repo .BranchName :
82
+ ctx .Data ["DefaultBranch" ] = branches [i ]
83
83
case branches [i ].Commit .Committer .When .Add (30 * 24 * time .Hour ).After (now ): // 30 days
84
84
activeBranches = append (activeBranches , branches [i ])
85
85
case branches [i ].Commit .Committer .When .Add (3 * 30 * 24 * time .Hour ).Before (now ): // 90 days
86
86
staleBranches = append (staleBranches , branches [i ])
87
87
}
88
88
}
89
89
90
- c .Data ["ActiveBranches" ] = activeBranches
91
- c .Data ["StaleBranches" ] = staleBranches
92
- c .HTML (200 , tplBranchOverview )
90
+ ctx .Data ["ActiveBranches" ] = activeBranches
91
+ ctx .Data ["StaleBranches" ] = staleBranches
92
+ ctx .HTML (200 , tplBranchOverview )
93
93
}
94
94
95
95
// AllBranches all branches UI
96
- func AllBranches (c * context.Context ) {
97
- c .Data ["Title" ] = c .Tr ("repo.git_branches" )
98
- c .Data ["PageIsBranchesAll" ] = true
96
+ func AllBranches (ctx * context.Context ) {
97
+ ctx .Data ["Title" ] = ctx .Tr ("repo.git_branches" )
98
+ ctx .Data ["PageIsBranchesAll" ] = true
99
99
100
- branches := loadBranches (c )
101
- if c .Written () {
100
+ branches := loadBranches (ctx )
101
+ if ctx .Written () {
102
102
return
103
103
}
104
- c .Data ["Branches" ] = branches
104
+ ctx .Data ["Branches" ] = branches
105
105
106
- c .HTML (200 , tplBranchAll )
106
+ ctx .HTML (200 , tplBranchAll )
107
107
}
108
108
109
109
// DeleteBranchPost executes branch deletation operation
110
- func DeleteBranchPost (c * context.Context ) {
111
- branchName := c .Params ("*" )
112
- commitID := c .Query ("commit" )
110
+ func DeleteBranchPost (ctx * context.Context ) {
111
+ branchName := ctx .Params ("*" )
112
+ commitID := ctx .Query ("commit" )
113
113
114
114
defer func () {
115
- redirectTo := c .Query ("redirect_to" )
115
+ redirectTo := ctx .Query ("redirect_to" )
116
116
if len (redirectTo ) == 0 {
117
- redirectTo = c .Repo .RepoLink
117
+ redirectTo = ctx .Repo .RepoLink
118
118
}
119
- c .Redirect (redirectTo )
119
+ ctx .Redirect (redirectTo )
120
120
}()
121
121
122
- if ! c .Repo .GitRepo .IsBranchExist (branchName ) {
122
+ if ! ctx .Repo .GitRepo .IsBranchExist (branchName ) {
123
123
return
124
124
}
125
125
if len (commitID ) > 0 {
126
- branchCommitID , err := c .Repo .GitRepo .GetBranchCommitID (branchName )
126
+ branchCommitID , err := ctx .Repo .GitRepo .GetBranchCommitID (branchName )
127
127
if err != nil {
128
128
log .Error (2 , "GetBranchCommitID: %v" , err )
129
129
return
130
130
}
131
131
132
132
if branchCommitID != commitID {
133
- c .Flash .Error (c .Tr ("repo.pulls.delete_branch_has_new_commits" ))
133
+ ctx .Flash .Error (ctx .Tr ("repo.pulls.delete_branch_has_new_commits" ))
134
134
return
135
135
}
136
136
}
137
137
138
- if err := c .Repo .GitRepo .DeleteBranch (branchName , git.DeleteBranchOptions {
138
+ if err := ctx .Repo .GitRepo .DeleteBranch (branchName , git.DeleteBranchOptions {
139
139
Force : true ,
140
140
}); err != nil {
141
141
log .Error (2 , "DeleteBranch '%s': %v" , branchName , err )
0 commit comments