Skip to content

Commit

Permalink
Merge branch 'main' into foldable-folders
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Feb 12, 2023
2 parents ab887b3 + 51ab495 commit 4726608
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ linters:
fast: false

run:
go: 1.20
go: "1.20"
timeout: 10m
skip-dirs:
- node_modules
Expand Down
7 changes: 5 additions & 2 deletions models/db/sql_postgres_with_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) {
}
schemaValue, _ := driver.String.ConvertValue(setting.Database.Schema)

if execer, ok := conn.(driver.Execer); ok {
// golangci lint is incorrect here - there is no benefit to using driver.ExecerContext here
// and in any case pq does not implement it
if execer, ok := conn.(driver.Execer); ok { //nolint
_, err := execer.Exec(`SELECT set_config(
'search_path',
$1 || ',' || current_setting('search_path'),
Expand All @@ -61,7 +63,8 @@ func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) {

// driver.String.ConvertValue will never return err for string

_, err = stmt.Exec([]driver.Value{schemaValue})
// golangci lint is incorrect here - there is no benefit to using stmt.ExecWithContext here
_, err = stmt.Exec([]driver.Value{schemaValue}) //nolint
if err != nil {
_ = conn.Close()
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions modules/lfs/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
package lfs

import (
"fmt"
"net/url"
"os"
"path"
"path/filepath"
"strings"

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/util"
)

// DetermineEndpoint determines an endpoint from the clone url or uses the specified LFS url.
Expand Down Expand Up @@ -95,7 +95,7 @@ func endpointFromLocalPath(path string) *url.URL {
return nil
}

path = fmt.Sprintf("file://%s%s", slash, filepath.ToSlash(path))
path = "file://" + slash + util.PathEscapeSegments(filepath.ToSlash(path))

u, _ := url.Parse(path)

Expand Down
9 changes: 5 additions & 4 deletions services/repository/files/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
)

// ContentType repo content type
Expand Down Expand Up @@ -158,7 +159,7 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
return nil, fmt.Errorf("no commit found for the ref [ref: %s]", ref)
}

selfURL, err := url.Parse(fmt.Sprintf("%s/contents/%s?ref=%s", repo.APIURL(), treePath, origRef))
selfURL, err := url.Parse(repo.APIURL() + "/contents/" + util.PathEscapeSegments(treePath) + "?ref=" + url.QueryEscape(origRef))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -217,23 +218,23 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
}
// Handle links
if entry.IsRegular() || entry.IsLink() {
downloadURL, err := url.Parse(fmt.Sprintf("%s/raw/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath))
downloadURL, err := url.Parse(repo.HTMLURL() + "/raw/" + url.PathEscape(string(refType)) + "/" + util.PathEscapeSegments(ref) + "/" + util.PathEscapeSegments(treePath))
if err != nil {
return nil, err
}
downloadURLString := downloadURL.String()
contentsResponse.DownloadURL = &downloadURLString
}
if !entry.IsSubModule() {
htmlURL, err := url.Parse(fmt.Sprintf("%s/src/%s/%s/%s", repo.HTMLURL(), refType, ref, treePath))
htmlURL, err := url.Parse(repo.HTMLURL() + "/src/" + url.PathEscape(string(refType)) + "/" + util.PathEscapeSegments(ref) + "/" + util.PathEscapeSegments(treePath))
if err != nil {
return nil, err
}
htmlURLString := htmlURL.String()
contentsResponse.HTMLURL = &htmlURLString
contentsResponse.Links.HTMLURL = &htmlURLString

gitURL, err := url.Parse(fmt.Sprintf("%s/git/blobs/%s", repo.APIURL(), entry.ID.String()))
gitURL, err := url.Parse(repo.APIURL() + "/git/blobs/" + url.PathEscape(entry.ID.String()))
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions web_src/less/_base.less
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,7 @@ footer {
}
}

/* TODO: remove in favor of .hidden helper */
.hide {
display: none;

Expand Down
1 change: 1 addition & 0 deletions web_src/less/helpers.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/* below class names match Tailwind CSS */
.pointer-events-none { pointer-events: none !important; }
.relative { position: relative !important; }
.hidden { display: none !important; }

.mono {
font-family: var(--fonts-monospace) !important;
Expand Down

0 comments on commit 4726608

Please sign in to comment.