forked from kevadesu/forgejo
[gitea] week 2025-02 cherry pick (gitea/main -> forgejo) (#6471)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6471 Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
commit
4261301dfb
34 changed files with 341 additions and 127 deletions
|
@ -176,3 +176,14 @@ func (repo *Repository) LsTree(ref string, filenames ...string) ([]string, error
|
|||
|
||||
return filelist, err
|
||||
}
|
||||
|
||||
// GetTreePathLatestCommitID returns the latest commit of a tree path
|
||||
func (repo *Repository) GetTreePathLatestCommit(refName, treePath string) (*Commit, error) {
|
||||
stdout, _, err := NewCommand(repo.Ctx, "rev-list", "-1").
|
||||
AddDynamicArguments(refName).AddDashesAndList(treePath).
|
||||
RunStdString(&RunOpts{Dir: repo.Path})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return repo.GetCommit(strings.TrimSpace(stdout))
|
||||
}
|
||||
|
|
|
@ -26,3 +26,18 @@ func TestSubTree_Issue29101(t *testing.T) {
|
|||
assert.True(t, IsErrNotExist(err))
|
||||
}
|
||||
}
|
||||
|
||||
func Test_GetTreePathLatestCommit(t *testing.T) {
|
||||
repo, err := openRepositoryWithDefaultContext(filepath.Join(testReposDir, "repo6_blame"))
|
||||
require.NoError(t, err)
|
||||
defer repo.Close()
|
||||
|
||||
commitID, err := repo.GetBranchCommitID("master")
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "544d8f7a3b15927cddf2299b4b562d6ebd71b6a7", commitID)
|
||||
|
||||
commit, err := repo.GetTreePathLatestCommit("master", "blame.txt")
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, commit)
|
||||
assert.EqualValues(t, "45fb6cbc12f970b04eacd5cd4165edd11c8d7376", commit.ID.String())
|
||||
}
|
||||
|
|
|
@ -168,3 +168,22 @@ func EnvironmentToConfig(cfg ConfigProvider, envs []string) (changed bool) {
|
|||
}
|
||||
return changed
|
||||
}
|
||||
|
||||
// InitGiteaEnvVars initializes the environment variables for gitea
|
||||
func InitGiteaEnvVars() {
|
||||
// Ideally Gitea should only accept the environment variables which it clearly knows instead of unsetting the ones it doesn't want,
|
||||
// but the ideal behavior would be a breaking change, and it seems not bringing enough benefits to end users,
|
||||
// so at the moment we could still keep "unsetting the unnecessary environments"
|
||||
|
||||
// HOME is managed by Gitea, Gitea's git should use "HOME/.gitconfig".
|
||||
// But git would try "XDG_CONFIG_HOME/git/config" first if "HOME/.gitconfig" does not exist,
|
||||
// then our git.InitFull would still write to "XDG_CONFIG_HOME/git/config" if XDG_CONFIG_HOME is set.
|
||||
_ = os.Unsetenv("XDG_CONFIG_HOME")
|
||||
|
||||
_ = os.Unsetenv("GIT_AUTHOR_NAME")
|
||||
_ = os.Unsetenv("GIT_AUTHOR_EMAIL")
|
||||
_ = os.Unsetenv("GIT_AUTHOR_DATE")
|
||||
_ = os.Unsetenv("GIT_COMMITTER_NAME")
|
||||
_ = os.Unsetenv("GIT_COMMITTER_EMAIL")
|
||||
_ = os.Unsetenv("GIT_COMMITTER_DATE")
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ package setting
|
|||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
// CORSConfig defines CORS settings
|
||||
|
@ -28,7 +26,4 @@ var CORSConfig = struct {
|
|||
|
||||
func loadCorsFrom(rootCfg ConfigProvider) {
|
||||
mustMapSetting(rootCfg, "cors", &CORSConfig)
|
||||
if CORSConfig.Enabled {
|
||||
log.Info("CORS Service Enabled")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ func IndexerGlobFromString(globstr string) []Glob {
|
|||
expr = strings.TrimSpace(expr)
|
||||
if expr != "" {
|
||||
if g, err := glob.Compile(expr, '.', '/'); err != nil {
|
||||
log.Info("Invalid glob expression '%s' (skipped): %v", expr, err)
|
||||
log.Warn("Invalid glob expression '%s' (skipped): %v", expr, err)
|
||||
} else {
|
||||
extarr = append(extarr, Glob{glob: g, pattern: expr})
|
||||
}
|
||||
|
|
|
@ -263,8 +263,6 @@ func loadMailerFrom(rootCfg ConfigProvider) {
|
|||
MailService.OverrideEnvelopeFrom = true
|
||||
MailService.EnvelopeFrom = parsed.Address
|
||||
}
|
||||
|
||||
log.Info("Mail Service Enabled")
|
||||
}
|
||||
|
||||
func loadRegisterMailFrom(rootCfg ConfigProvider) {
|
||||
|
@ -275,7 +273,6 @@ func loadRegisterMailFrom(rootCfg ConfigProvider) {
|
|||
return
|
||||
}
|
||||
Service.RegisterEmailConfirm = true
|
||||
log.Info("Register Mail Service Enabled")
|
||||
}
|
||||
|
||||
func loadNotifyMailFrom(rootCfg ConfigProvider) {
|
||||
|
@ -286,7 +283,6 @@ func loadNotifyMailFrom(rootCfg ConfigProvider) {
|
|||
return
|
||||
}
|
||||
Service.EnableNotifyMail = true
|
||||
log.Info("Notify Mail Service Enabled")
|
||||
}
|
||||
|
||||
func tryResolveAddr(addr string) []net.IPAddr {
|
||||
|
|
|
@ -73,6 +73,4 @@ func loadSessionFrom(rootCfg ConfigProvider) {
|
|||
SessionConfig.ProviderConfig = string(shadowConfig)
|
||||
SessionConfig.OriginalProvider = SessionConfig.Provider
|
||||
SessionConfig.Provider = "VirtualSession"
|
||||
|
||||
log.Info("Session Service Enabled")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ func loadTimeFrom(rootCfg ConfigProvider) {
|
|||
if err != nil {
|
||||
log.Fatal("Load time zone failed: %v", err)
|
||||
}
|
||||
log.Info("Default UI Location is %v", zone)
|
||||
}
|
||||
if DefaultUILocation == nil {
|
||||
DefaultUILocation = time.Local
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue