mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-16 00:01:18 -04:00
Compare commits
No commits in common. "9a6d78eaa89ffbf60a1f579bd220fe0cfb720e3b" and "f430050d244f8bbefc0726b786d49b70bf6a8234" have entirely different histories.
9a6d78eaa8
...
f430050d24
4
Makefile
4
Makefile
@ -740,9 +740,9 @@ $(DIST_DIRS):
|
|||||||
|
|
||||||
.PHONY: release-windows
|
.PHONY: release-windows
|
||||||
release-windows: | $(DIST_DIRS)
|
release-windows: | $(DIST_DIRS)
|
||||||
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
|
||||||
ifeq (,$(findstring gogit,$(TAGS)))
|
ifeq (,$(findstring gogit,$(TAGS)))
|
||||||
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'osusergo gogit $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION)-gogit .
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo gogit $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION)-gogit .
|
||||||
endif
|
endif
|
||||||
ifeq ($(CI),true)
|
ifeq ($(CI),true)
|
||||||
cp /build/* $(DIST)/binaries
|
cp /build/* $(DIST)/binaries
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
"code.gitea.io/gitea/models/unit"
|
"code.gitea.io/gitea/models/unit"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
"code.gitea.io/gitea/modules/container"
|
"code.gitea.io/gitea/modules/container"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
|
||||||
"code.gitea.io/gitea/modules/structs"
|
"code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
|
|
||||||
@ -499,12 +498,8 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
|
|||||||
// Only show a repo that either has a topic or description.
|
// Only show a repo that either has a topic or description.
|
||||||
subQueryCond := builder.NewCond()
|
subQueryCond := builder.NewCond()
|
||||||
|
|
||||||
// Topic checking. Topics are present.
|
// Topic checking. Topics is non-null.
|
||||||
if setting.Database.UsePostgreSQL { // postgres stores the topics as json and not as text
|
subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"}))
|
||||||
subQueryCond = subQueryCond.Or(builder.And(builder.NotNull{"topics"}, builder.Neq{"(topics)::text": "[]"}))
|
|
||||||
} else {
|
|
||||||
subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"}))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Description checking. Description not empty.
|
// Description checking. Description not empty.
|
||||||
subQueryCond = subQueryCond.Or(builder.Neq{"description": ""})
|
subQueryCond = subQueryCond.Or(builder.Neq{"description": ""})
|
||||||
|
@ -185,7 +185,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,
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
@ -287,36 +286,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)
|
||||||
}
|
}
|
||||||
|
@ -169,13 +169,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(1)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
size, err := getDirectorySize(repo.RepoPath())
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.EqualValues(t, size, repo.Size)
|
|
||||||
}
|
|
||||||
|
@ -23,6 +23,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) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
function displayError(el, err) {
|
function displayError(el, err) {
|
||||||
const target = targetElement(el);
|
const target = targetElement(el);
|
||||||
target.classList.remove('is-loading');
|
target.remove('is-loading');
|
||||||
const errorNode = document.createElement('div');
|
const errorNode = document.createElement('div');
|
||||||
errorNode.setAttribute('class', 'ui message error markup-block-error mono');
|
errorNode.setAttribute('class', 'ui message error markup-block-error mono');
|
||||||
errorNode.textContent = err.str || err.message || String(err);
|
errorNode.textContent = err.str || err.message || String(err);
|
||||||
@ -23,16 +23,12 @@ export async function renderMath() {
|
|||||||
|
|
||||||
for (const el of els) {
|
for (const el of els) {
|
||||||
const source = el.textContent;
|
const source = el.textContent;
|
||||||
const displayMode = el.classList.contains('display');
|
const options = {display: el.classList.contains('display')};
|
||||||
const nodeName = displayMode ? 'p' : 'span';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const tempEl = document.createElement(nodeName);
|
const markup = katex.renderToString(source, options);
|
||||||
katex.render(source, tempEl, {
|
const tempEl = document.createElement(options.display ? 'p' : 'span');
|
||||||
maxSize: 25,
|
tempEl.innerHTML = markup;
|
||||||
maxExpand: 50,
|
|
||||||
displayMode,
|
|
||||||
});
|
|
||||||
targetElement(el).replaceWith(tempEl);
|
targetElement(el).replaceWith(tempEl);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
displayError(el, error);
|
displayError(el, error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user