mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-14 00:01:44 -04:00
Compare commits
No commits in common. "20e3ffd2085d7066b3206809dfae7b6ebd59cb5d" and "99cf0d394ea1f949b72aef2c25e74e67a4ca1791" have entirely different histories.
20e3ffd208
...
99cf0d394e
@ -192,5 +192,5 @@ And so you could write some CSS:
|
|||||||
Add your stylesheet to your custom directory e.g `custom/public/css/my-style-XXXXX.css` and import it using a custom header file `custom/templates/custom/header.tmpl`:
|
Add your stylesheet to your custom directory e.g `custom/public/css/my-style-XXXXX.css` and import it using a custom header file `custom/templates/custom/header.tmpl`:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="{{AppSubUrl}}/assets/css/my-style-XXXXX.css" />
|
<link type="text/css" href="{{AppSubUrl}}/assets/css/my-style-XXXXX.css" />
|
||||||
```
|
```
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
fork_id: 0
|
fork_id: 0
|
||||||
is_template: false
|
is_template: false
|
||||||
template_id: 0
|
template_id: 0
|
||||||
size: 6708
|
size: 0
|
||||||
is_fsck_enabled: true
|
is_fsck_enabled: true
|
||||||
close_issues_via_commit_in_any_branch: false
|
close_issues_via_commit_in_any_branch: false
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ func ChangeRepositoryName(doer *user_model.User, repo *Repository, newRepoName s
|
|||||||
return committer.Commit()
|
return committer.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRepoSize updates the repository size, calculating it using getDirectorySize
|
// UpdateRepoSize updates the repository size, calculating it using util.GetDirectorySize
|
||||||
func UpdateRepoSize(ctx context.Context, repoID, size int64) error {
|
func UpdateRepoSize(ctx context.Context, repoID, size int64) error {
|
||||||
_, err := db.GetEngine(ctx).ID(repoID).Cols("size").NoAutoTime().Update(&Repository{
|
_, err := db.GetEngine(ctx).ID(repoID).Cols("size").NoAutoTime().Update(&Repository{
|
||||||
Size: size,
|
Size: size,
|
||||||
|
5
modules/markup/external/external.go
vendored
5
modules/markup/external/external.go
vendored
@ -4,7 +4,6 @@
|
|||||||
package external
|
package external
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@ -133,13 +132,11 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
|
|||||||
if !p.IsInputFile {
|
if !p.IsInputFile {
|
||||||
cmd.Stdin = input
|
cmd.Stdin = input
|
||||||
}
|
}
|
||||||
var stderr bytes.Buffer
|
|
||||||
cmd.Stdout = output
|
cmd.Stdout = output
|
||||||
cmd.Stderr = &stderr
|
|
||||||
process.SetSysProcAttribute(cmd)
|
process.SetSysProcAttribute(cmd)
|
||||||
|
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
return fmt.Errorf("%s render run command %s %v failed: %w\nStderr: %s", p.Name(), commands[0], args, err, stderr.String())
|
return fmt.Errorf("%s render run command %s %v failed: %w", p.Name(), commands[0], args, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
@ -286,36 +285,9 @@ func CreateRepository(doer, u *user_model.User, opts CreateRepoOptions) (*repo_m
|
|||||||
return repo, nil
|
return repo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const notRegularFileMode = os.ModeSymlink | os.ModeNamedPipe | os.ModeSocket | os.ModeDevice | os.ModeCharDevice | os.ModeIrregular
|
// UpdateRepoSize updates the repository size, calculating it using util.GetDirectorySize
|
||||||
|
|
||||||
// getDirectorySize returns the disk consumption for a given path
|
|
||||||
func getDirectorySize(path string) (int64, error) {
|
|
||||||
var size int64
|
|
||||||
err := filepath.WalkDir(path, func(_ string, info os.DirEntry, err error) error {
|
|
||||||
if err != nil {
|
|
||||||
if os.IsNotExist(err) { // ignore the error because the file maybe deleted during traversing.
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if info.IsDir() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
f, err := info.Info()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if (f.Mode() & notRegularFileMode) == 0 {
|
|
||||||
size += f.Size()
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
return size, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateRepoSize updates the repository size, calculating it using getDirectorySize
|
|
||||||
func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error {
|
func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error {
|
||||||
size, err := getDirectorySize(repo.RepoPath())
|
size, err := util.GetDirectorySize(repo.RepoPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("updateSize: %w", err)
|
return fmt.Errorf("updateSize: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -168,13 +168,3 @@ func TestUpdateRepositoryVisibilityChanged(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, act.IsPrivate)
|
assert.True(t, act.IsPrivate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetDirectorySize(t *testing.T) {
|
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
||||||
repo, err := repo_model.GetRepositoryByID(db.DefaultContext, 1)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
size, err := getDirectorySize(repo.RepoPath())
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.EqualValues(t, size, repo.Size)
|
|
||||||
}
|
|
||||||
|
@ -22,6 +22,20 @@ func EnsureAbsolutePath(path, absoluteBase string) string {
|
|||||||
return filepath.Join(absoluteBase, path)
|
return filepath.Join(absoluteBase, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const notRegularFileMode os.FileMode = os.ModeSymlink | os.ModeNamedPipe | os.ModeSocket | os.ModeDevice | os.ModeCharDevice | os.ModeIrregular
|
||||||
|
|
||||||
|
// GetDirectorySize returns the disk consumption for a given path
|
||||||
|
func GetDirectorySize(path string) (int64, error) {
|
||||||
|
var size int64
|
||||||
|
err := filepath.Walk(path, func(_ string, info os.FileInfo, err error) error {
|
||||||
|
if info != nil && (info.Mode()¬RegularFileMode) == 0 {
|
||||||
|
size += info.Size()
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
return size, err
|
||||||
|
}
|
||||||
|
|
||||||
// IsDir returns true if given path is a directory,
|
// IsDir returns true if given path is a directory,
|
||||||
// or returns false when it's a file or does not exist.
|
// or returns false when it's a file or does not exist.
|
||||||
func IsDir(dir string) (bool, error) {
|
func IsDir(dir string) (bool, error) {
|
||||||
|
@ -1379,7 +1379,7 @@ issues.label_title = Label name
|
|||||||
issues.label_description = Label description
|
issues.label_description = Label description
|
||||||
issues.label_color = Label color
|
issues.label_color = Label color
|
||||||
issues.label_count = %d labels
|
issues.label_count = %d labels
|
||||||
issues.label_open_issues = %d open issues/pull requests
|
issues.label_open_issues = %d open issues
|
||||||
issues.label_edit = Edit
|
issues.label_edit = Edit
|
||||||
issues.label_delete = Delete
|
issues.label_delete = Delete
|
||||||
issues.label_modify = Edit Label
|
issues.label_modify = Edit Label
|
||||||
|
@ -143,7 +143,7 @@
|
|||||||
{{$.locale.Tr "repo.diff.file_suppressed_line_too_long"}}
|
{{$.locale.Tr "repo.diff.file_suppressed_line_too_long"}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$.locale.Tr "repo.diff.file_suppressed"}}
|
{{$.locale.Tr "repo.diff.file_suppressed"}}
|
||||||
<a class="ui basic tiny button diff-load-button" data-href="{{$.Link}}?file-only=true&files={{$file.Name}}&files={{$file.OldName}}">{{$.locale.Tr "repo.diff.load"}}</a>
|
<a class="ui basic tiny button diff-show-more-button" data-href="{{$.Link}}?file-only=true&files={{$file.Name}}&files={{$file.OldName}}">{{$.locale.Tr "repo.diff.load"}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$.locale.Tr "repo.diff.bin_not_shown"}}
|
{{$.locale.Tr "repo.diff.bin_not_shown"}}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<DiffFileTreeItem v-for="item in fileTree" :key="item.name" :item="item" />
|
<DiffFileTreeItem v-for="item in fileTree" :key="item.name" :item="item" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isIncomplete" id="diff-too-many-files-stats" class="pt-2">
|
<div v-if="isIncomplete" id="diff-too-many-files-stats" class="pt-2">
|
||||||
<span class="mr-2">{{ tooManyFilesMessage }}</span><a :class="['ui', 'basic', 'tiny', 'button', isLoadingNewData === true ? 'disabled' : '']" id="diff-show-more-files-stats" @click.stop="loadMoreData">{{ showMoreMessage }}</a>
|
<span>{{ tooManyFilesMessage }}</span><a :class="['ui', 'basic', 'tiny', 'button', isLoadingNewData === true ? 'disabled' : '']" id="diff-show-more-files-stats" @click.stop="loadMoreData">{{ showMoreMessage }}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -94,9 +94,6 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
// ensure correct buttons when we are mounted to the dom
|
// ensure correct buttons when we are mounted to the dom
|
||||||
this.adjustToggleButton(this.fileTreeIsVisible);
|
this.adjustToggleButton(this.fileTreeIsVisible);
|
||||||
// replace the pageData.diffFileInfo.files with our watched data so we get updates
|
|
||||||
pageData.diffFileInfo.files = this.files;
|
|
||||||
|
|
||||||
document.querySelector('.diff-toggle-file-tree-button').addEventListener('click', this.toggleVisibility);
|
document.querySelector('.diff-toggle-file-tree-button').addEventListener('click', this.toggleVisibility);
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
|
@ -119,47 +119,26 @@ function onShowMoreFiles() {
|
|||||||
|
|
||||||
export function doLoadMoreFiles(link, diffEnd, callback) {
|
export function doLoadMoreFiles(link, diffEnd, callback) {
|
||||||
const url = `${link}?skip-to=${diffEnd}&file-only=true`;
|
const url = `${link}?skip-to=${diffEnd}&file-only=true`;
|
||||||
loadMoreFiles(url, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadMoreFiles(url, callback) {
|
|
||||||
const $target = $('a#diff-show-more-files');
|
|
||||||
if ($target.hasClass('disabled')) {
|
|
||||||
callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$target.addClass('disabled');
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url,
|
url,
|
||||||
}).done((resp) => {
|
}).done((resp) => {
|
||||||
if (!resp) {
|
if (!resp) {
|
||||||
$target.removeClass('disabled');
|
|
||||||
callback(resp);
|
callback(resp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$('#diff-incomplete').replaceWith($(resp).find('#diff-file-boxes').children());
|
|
||||||
// By simply rerunning the script we add the new data to our existing
|
// By simply rerunning the script we add the new data to our existing
|
||||||
// pagedata object. this triggers vue and the filetree and filelist will
|
// pagedata object. this triggers vue and the filetree and filelist will
|
||||||
// render the new elements.
|
// render the new elements.
|
||||||
$('body').append($(resp).find('script#diff-data-script'));
|
$('body').append($(resp).find('script#diff-data-script'));
|
||||||
onShowMoreFiles();
|
|
||||||
callback(resp);
|
callback(resp);
|
||||||
}).fail(() => {
|
}).fail(() => {
|
||||||
$target.removeClass('disabled');
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initRepoDiffShowMore() {
|
export function initRepoDiffShowMore() {
|
||||||
$(document).on('click', 'a#diff-show-more-files', (e) => {
|
$(document).on('click', 'a.diff-show-more-button', (e) => {
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
const $target = $(e.target);
|
|
||||||
loadMoreFiles($target.data('href'), () => {});
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('click', 'a.diff-load-button', (e) => {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const $target = $(e.target);
|
const $target = $(e.target);
|
||||||
|
|
||||||
|
@ -1667,9 +1667,6 @@
|
|||||||
background-color: var(--color-teal);
|
background-color: var(--color-teal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.button {
|
|
||||||
padding: 8px 12px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.diff-box .header:not(.resolved-placeholder) {
|
.diff-box .header:not(.resolved-placeholder) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user