@@ -110,11 +110,11 @@ func GetAnnotatedTag(ctx *context.APIContext) {
110
110
}
111
111
}
112
112
113
- // DeleteTag delete a specific tag of in a repository by name
114
- func DeleteTag (ctx * context.APIContext ) {
115
- // swagger:operation DELETE /repos/{owner}/{repo}/tags/{tag} repository repoDeleteTag
113
+ // GetTag get the tag of a repository
114
+ func GetTag (ctx * context.APIContext ) {
115
+ // swagger:operation GET /repos/{owner}/{repo}/tags/{tag} repository repoGetTag
116
116
// ---
117
- // summary: Delete a repository's tag by name
117
+ // summary: Get the tag of a repository by tag name
118
118
// produces:
119
119
// - application/json
120
120
// parameters:
@@ -130,37 +130,22 @@ func DeleteTag(ctx *context.APIContext) {
130
130
// required: true
131
131
// - name: tag
132
132
// in: path
133
- // description: name of tag to delete
133
+ // description: name of tag
134
134
// type: string
135
135
// required: true
136
136
// responses:
137
- // "204 ":
137
+ // "200 ":
138
138
// "$ref": "#/responses/empty"
139
139
// "404":
140
140
// "$ref": "#/responses/notFound"
141
- // "409":
142
- // "$ref": "#/responses/conflict"
141
+ tagName := ctx .Params ("tag" )
143
142
144
- tag , err := models . GetRelease ( ctx .Repo .Repository . ID , ctx . Params ( "tag" ) )
143
+ tag , err := ctx .Repo .GitRepo . GetTag ( tagName )
145
144
if err != nil {
146
- if models .IsErrReleaseNotExist (err ) {
147
- ctx .NotFound ()
148
- return
149
- }
150
- ctx .Error (http .StatusInternalServerError , "GetRelease" , err )
151
- return
152
- }
153
-
154
- if ! tag .IsTag {
155
- ctx .Error (http .StatusConflict , "IsTag" , errors .New ("a tag attached to a release cannot be deleted directly" ))
145
+ ctx .NotFound (tagName )
156
146
return
157
147
}
158
-
159
- if err = releaseservice .DeleteReleaseByID (tag .ID , ctx .User , true ); err != nil {
160
- ctx .Error (http .StatusInternalServerError , "DeleteReleaseByID" , err )
161
- }
162
-
163
- ctx .Status (http .StatusNoContent )
148
+ ctx .JSON (http .StatusOK , convert .ToTag (ctx .Repo .Repository , tag ))
164
149
}
165
150
166
151
// CreateTag create a new git tag in a repository
@@ -221,3 +206,56 @@ func CreateTag(ctx *context.APIContext) {
221
206
}
222
207
ctx .JSON (http .StatusCreated , convert .ToTag (ctx .Repo .Repository , tag ))
223
208
}
209
+
210
+ // DeleteTag delete a specific tag of in a repository by name
211
+ func DeleteTag (ctx * context.APIContext ) {
212
+ // swagger:operation DELETE /repos/{owner}/{repo}/tags/{tag} repository repoDeleteTag
213
+ // ---
214
+ // summary: Delete a repository's tag by name
215
+ // produces:
216
+ // - application/json
217
+ // parameters:
218
+ // - name: owner
219
+ // in: path
220
+ // description: owner of the repo
221
+ // type: string
222
+ // required: true
223
+ // - name: repo
224
+ // in: path
225
+ // description: name of the repo
226
+ // type: string
227
+ // required: true
228
+ // - name: tag
229
+ // in: path
230
+ // description: name of tag to delete
231
+ // type: string
232
+ // required: true
233
+ // responses:
234
+ // "204":
235
+ // "$ref": "#/responses/empty"
236
+ // "404":
237
+ // "$ref": "#/responses/notFound"
238
+ // "409":
239
+ // "$ref": "#/responses/conflict"
240
+
241
+ tag , err := models .GetRelease (ctx .Repo .Repository .ID , ctx .Params ("tag" ))
242
+ if err != nil {
243
+ if models .IsErrReleaseNotExist (err ) {
244
+ ctx .NotFound ()
245
+ return
246
+ }
247
+ ctx .Error (http .StatusInternalServerError , "GetRelease" , err )
248
+ return
249
+ }
250
+
251
+ if ! tag .IsTag {
252
+ ctx .Error (http .StatusConflict , "IsTag" , errors .New ("a tag attached to a release cannot be deleted directly" ))
253
+ return
254
+ }
255
+
256
+ if err = releaseservice .DeleteReleaseByID (tag .ID , ctx .User , true ); err != nil {
257
+ ctx .Error (http .StatusInternalServerError , "DeleteReleaseByID" , err )
258
+ }
259
+
260
+ ctx .Status (http .StatusNoContent )
261
+ }
0 commit comments