-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Added URL mapping for Release attachments like on github.com #1707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
techknowlogick
merged 23 commits into
go-gitea:master
from
al-sabr:origin/git-style-release-url-attachments
Jan 6, 2019
Merged
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5051282
Made changes from Staff code review
c3a4475
New file infos added for releases
90e8b46
Refactored code and create File utility package
1bc6f84
Refactored code to compile without error
b194556
Refactored code to compile without error
7570b10
Reverted returned errors to correct values
1b8ce6e
Import bothered someone and wanted his wishlist to
c261b02
Fixed the release downloads without signin
1372dde
Removed commented code
591e50a
Removed unnecessary variable from code
730c003
Fixed comment for function FormatFileSize
c7c3488
repo.MustBeNotBare was missing
df08447
Optimize file size formatting
lafriks 09d3e0e
Merge branch 'master' into origin/git-style-release-url-attachments
lafriks 3dd1640
Fix spacing
lafriks bedf8ea
Delete unnneded functions
lafriks 77eb06b
Unneeded function
lafriks 6a0b980
Remove unneeded functions
lafriks 1388b6b
Fix build
lafriks 90e8b7c
Fix build errors
lafriks b6ce3f6
Restore accidentally removed function
lafriks 0c6b36c
Fix build finally :)
lafriks 926e486
Merge branch 'master' into origin/git-style-release-url-attachments
lafriks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2017 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package util | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// FormatFileSizeToMB formats the filesize | ||
func FormatFileSize(bytes int64) string { | ||
var result float64 | ||
var format string | ||
var measure string | ||
if bytes < 10240 { // bytes | ||
result = float64(bytes) / float64(1048) | ||
measure = "Bytes" | ||
} else if bytes < 1048576 { // kbytes | ||
result = float64(bytes) / float64(102400) | ||
measure = "KB" | ||
} else if bytes < 1048576000 { // mbytes | ||
result = float64(bytes) / float64(1048576) | ||
measure = "MB" | ||
} else if bytes < 1048576000000 { // gbytes | ||
result = float64(bytes) / float64(1048576000) | ||
measure = "GB" | ||
} else if bytes < 1048576000000000 { // tbytes | ||
lafriks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
result = float64(bytes) / float64(1048576000000) | ||
measure = "TB" | ||
} | ||
|
||
if result < 0.01 { | ||
format = "%.2f" | ||
result = 0.01 | ||
} else if result < 0.1 { | ||
format = "%.2f" | ||
} else { | ||
format = "%.1f" | ||
} | ||
return fmt.Sprintf(format, result) + " " + measure | ||
} | ||
|
||
// GetFileSize returns file size | ||
func GetFileSize(path string) int64 { | ||
stats, err := os.Stat(path) | ||
if err != nil { | ||
return -1 | ||
} | ||
return stats.Size() | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.