mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	Fix some trivial problems (#34579)
This commit is contained in:
		@@ -66,7 +66,7 @@ func getUserHeatmapData(ctx context.Context, user *user_model.User, team *organi
 | 
			
		||||
		Select(groupBy+" AS timestamp, count(user_id) as contributions").
 | 
			
		||||
		Table("action").
 | 
			
		||||
		Where(cond).
 | 
			
		||||
		And("created_unix > ?", timeutil.TimeStampNow()-31536000).
 | 
			
		||||
		And("created_unix > ?", timeutil.TimeStampNow()-(366+7)*86400). // (366+7) days to include the first week for the heatmap
 | 
			
		||||
		GroupBy(groupByName).
 | 
			
		||||
		OrderBy("timestamp").
 | 
			
		||||
		Find(&hdata)
 | 
			
		||||
 
 | 
			
		||||
@@ -97,17 +97,17 @@ func GetLanguageStats(repo *git.Repository, commitID string) (map[string]int64,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		isVendored := optional.None[bool]()
 | 
			
		||||
		isGenerated := optional.None[bool]()
 | 
			
		||||
		isDocumentation := optional.None[bool]()
 | 
			
		||||
		isDetectable := optional.None[bool]()
 | 
			
		||||
 | 
			
		||||
		attrs, err := checker.CheckPath(f.Name())
 | 
			
		||||
		attrLinguistGenerated := optional.None[bool]()
 | 
			
		||||
		if err == nil {
 | 
			
		||||
			if isVendored = attrs.GetVendored(); isVendored.ValueOrDefault(false) {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if isGenerated = attrs.GetGenerated(); isGenerated.ValueOrDefault(false) {
 | 
			
		||||
			if attrLinguistGenerated = attrs.GetGenerated(); attrLinguistGenerated.ValueOrDefault(false) {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@@ -169,7 +169,15 @@ func GetLanguageStats(repo *git.Repository, commitID string) (map[string]int64,
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if !isGenerated.Has() && enry.IsGenerated(f.Name(), content) {
 | 
			
		||||
 | 
			
		||||
		// if "generated" attribute is set, use it, otherwise use enry.IsGenerated to guess
 | 
			
		||||
		var isGenerated bool
 | 
			
		||||
		if attrLinguistGenerated.Has() {
 | 
			
		||||
			isGenerated = attrLinguistGenerated.Value()
 | 
			
		||||
		} else {
 | 
			
		||||
			isGenerated = enry.IsGenerated(f.Name(), content)
 | 
			
		||||
		}
 | 
			
		||||
		if isGenerated {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -103,7 +103,10 @@ func logPrinter(logger log.Logger) func(trigger Event, record *requestRecord) {
 | 
			
		||||
			status = v.WrittenStatus()
 | 
			
		||||
		}
 | 
			
		||||
		logf := logInfo
 | 
			
		||||
		if strings.HasPrefix(req.RequestURI, "/assets/") {
 | 
			
		||||
		// lower the log level for some specific requests, in most cases these logs are not useful
 | 
			
		||||
		if strings.HasPrefix(req.RequestURI, "/assets/") /* static assets */ ||
 | 
			
		||||
			req.RequestURI == "/user/events" /* Server-Sent Events (SSE) handler */ ||
 | 
			
		||||
			req.RequestURI == "/api/actions/runner.v1.RunnerService/FetchTask" /* Actions Runner polling */ {
 | 
			
		||||
			logf = logTrace
 | 
			
		||||
		}
 | 
			
		||||
		message := completedMessage
 | 
			
		||||
 
 | 
			
		||||
@@ -721,7 +721,7 @@ func serveBlob(ctx *context.Context, pfd *packages_model.PackageFileDescriptor)
 | 
			
		||||
	if u != nil {
 | 
			
		||||
		headers.Status = http.StatusTemporaryRedirect
 | 
			
		||||
		headers.Location = u.String()
 | 
			
		||||
 | 
			
		||||
		headers.ContentLength = 0 // do not set Content-Length for redirect responses
 | 
			
		||||
		setResponseHeaders(ctx.Resp, headers)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,10 +42,8 @@ type expansion struct {
 | 
			
		||||
var defaultTransformers = []transformer{
 | 
			
		||||
	{Name: "SNAKE", Transform: xstrings.ToSnakeCase},
 | 
			
		||||
	{Name: "KEBAB", Transform: xstrings.ToKebabCase},
 | 
			
		||||
	{Name: "CAMEL", Transform: func(str string) string {
 | 
			
		||||
		return xstrings.FirstRuneToLower(xstrings.ToCamelCase(str))
 | 
			
		||||
	}},
 | 
			
		||||
	{Name: "PASCAL", Transform: xstrings.ToCamelCase},
 | 
			
		||||
	{Name: "CAMEL", Transform: xstrings.ToCamelCase},
 | 
			
		||||
	{Name: "PASCAL", Transform: xstrings.ToPascalCase},
 | 
			
		||||
	{Name: "LOWER", Transform: strings.ToLower},
 | 
			
		||||
	{Name: "UPPER", Transform: strings.ToUpper},
 | 
			
		||||
	{Name: "TITLE", Transform: util.ToTitleCase},
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@ import (
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"github.com/stretchr/testify/require"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var giteaTemplate = []byte(`
 | 
			
		||||
@@ -65,3 +66,26 @@ func TestFileNameSanitize(t *testing.T) {
 | 
			
		||||
	assert.Equal(t, "_", fileNameSanitize("\u0000"))
 | 
			
		||||
	assert.Equal(t, "目标", fileNameSanitize("目标"))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestTransformers(t *testing.T) {
 | 
			
		||||
	cases := []struct {
 | 
			
		||||
		name     string
 | 
			
		||||
		expected string
 | 
			
		||||
	}{
 | 
			
		||||
		{"SNAKE", "abc_def_xyz"},
 | 
			
		||||
		{"KEBAB", "abc-def-xyz"},
 | 
			
		||||
		{"CAMEL", "abcDefXyz"},
 | 
			
		||||
		{"PASCAL", "AbcDefXyz"},
 | 
			
		||||
		{"LOWER", "abc_def-xyz"},
 | 
			
		||||
		{"UPPER", "ABC_DEF-XYZ"},
 | 
			
		||||
		{"TITLE", "Abc_def-Xyz"},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	input := "Abc_Def-XYZ"
 | 
			
		||||
	assert.Len(t, defaultTransformers, len(cases))
 | 
			
		||||
	for i, c := range cases {
 | 
			
		||||
		tf := defaultTransformers[i]
 | 
			
		||||
		require.Equal(t, c.name, tf.Name)
 | 
			
		||||
		assert.Equal(t, c.expected, tf.Transform(input), "case %s", c.name)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@
 | 
			
		||||
								<h3>{{ctx.Locale.Tr "repo.create_new_repo_command"}}</h3>
 | 
			
		||||
								<div class="markup">
 | 
			
		||||
									<pre><code>touch README.md
 | 
			
		||||
git init
 | 
			
		||||
git init{{if ne .Repository.ObjectFormatName "sha1"}} --object-format={{.Repository.ObjectFormatName}}{{end}}{{/* for sha256 repo, it needs to set "object-format" explicitly*/}}
 | 
			
		||||
{{if ne .Repository.DefaultBranch "master"}}git checkout -b {{.Repository.DefaultBranch}}{{end}}
 | 
			
		||||
git add README.md
 | 
			
		||||
git commit -m "first commit"
 | 
			
		||||
 
 | 
			
		||||
@@ -439,7 +439,8 @@ export default defineComponent({
 | 
			
		||||
});
 | 
			
		||||
</script>
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="ui container action-view-container">
 | 
			
		||||
  <!-- make the view container full width to make users easier to read logs -->
 | 
			
		||||
  <div class="ui fluid container">
 | 
			
		||||
    <div class="action-view-header">
 | 
			
		||||
      <div class="action-info-summary">
 | 
			
		||||
        <div class="action-info-summary-title">
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user