diff options
author | Unknwon <u@gogs.io> | 2017-03-13 04:32:20 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-03-13 04:32:20 -0400 |
commit | 1df54ea0cde038e2057d083078f952c072d0dc67 (patch) | |
tree | c5466e010f5ed8e236f5b021e669f9aa37ea0047 /models/attachment.go | |
parent | e6df2259abdeb75545f53a5ca4c247491b5c3d7f (diff) |
release: able to add attchments to release (#1614)
Added new config section '[release.attachment]’.
Diffstat (limited to 'models/attachment.go')
-rw-r--r-- | models/attachment.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/models/attachment.go b/models/attachment.go index a270b751..4ba6adcb 100644 --- a/models/attachment.go +++ b/models/attachment.go @@ -110,7 +110,7 @@ func GetAttachmentByUUID(uuid string) (*Attachment, error) { } func getAttachmentsByIssueID(e Engine, issueID int64) ([]*Attachment, error) { - attachments := make([]*Attachment, 0, 10) + attachments := make([]*Attachment, 0, 5) return attachments, e.Where("issue_id = ? AND comment_id = 0", issueID).Find(&attachments) } @@ -120,15 +120,25 @@ func GetAttachmentsByIssueID(issueID int64) ([]*Attachment, error) { } func getAttachmentsByCommentID(e Engine, commentID int64) ([]*Attachment, error) { - attachments := make([]*Attachment, 0, 10) + attachments := make([]*Attachment, 0, 5) return attachments, e.Where("comment_id=?", commentID).Find(&attachments) } -// GetAttachmentsByCommentID returns all attachments if comment by given ID. +// GetAttachmentsByCommentID returns all attachments of a comment. func GetAttachmentsByCommentID(commentID int64) ([]*Attachment, error) { return getAttachmentsByCommentID(x, commentID) } +func getAttachmentsByReleaseID(e Engine, releaseID int64) ([]*Attachment, error) { + attachments := make([]*Attachment, 0, 10) + return attachments, e.Where("release_id = ?", releaseID).Find(&attachments) +} + +// GetAttachmentsByReleaseID returns all attachments of a release. +func GetAttachmentsByReleaseID(releaseID int64) ([]*Attachment, error) { + return getAttachmentsByReleaseID(x, releaseID) +} + // DeleteAttachment deletes the given attachment and optionally the associated file. func DeleteAttachment(a *Attachment, remove bool) error { _, err := DeleteAttachments([]*Attachment{a}, remove) |