mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 15:53:07 -05:00
Merge pull request '[BUG] Workaround borked Git version' (#2342) from gusted/forgejo-bp-2335 into v1.21/forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2342 Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org> Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
45c0fa4905
2 changed files with 26 additions and 2 deletions
|
@ -34,7 +34,8 @@ var (
|
||||||
DefaultContext context.Context
|
DefaultContext context.Context
|
||||||
|
|
||||||
// SupportProcReceive version >= 2.29.0
|
// SupportProcReceive version >= 2.29.0
|
||||||
SupportProcReceive bool
|
SupportProcReceive bool
|
||||||
|
InvertedGitFlushEnv bool // 2.43.1
|
||||||
|
|
||||||
gitVersion *version.Version
|
gitVersion *version.Version
|
||||||
)
|
)
|
||||||
|
@ -186,6 +187,8 @@ func InitFull(ctx context.Context) (err error) {
|
||||||
}
|
}
|
||||||
SupportProcReceive = CheckGitVersionAtLeast("2.29") == nil
|
SupportProcReceive = CheckGitVersionAtLeast("2.29") == nil
|
||||||
|
|
||||||
|
InvertedGitFlushEnv = CheckGitVersionEqual("2.43.1") == nil
|
||||||
|
|
||||||
if setting.LFS.StartServer {
|
if setting.LFS.StartServer {
|
||||||
if CheckGitVersionAtLeast("2.1.2") != nil {
|
if CheckGitVersionAtLeast("2.1.2") != nil {
|
||||||
return errors.New("LFS server support requires Git >= 2.1.2")
|
return errors.New("LFS server support requires Git >= 2.1.2")
|
||||||
|
@ -314,6 +317,21 @@ func CheckGitVersionAtLeast(atLeast string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckGitVersionEqual checks if the git version is equal to the constraint version.
|
||||||
|
func CheckGitVersionEqual(equal string) error {
|
||||||
|
if _, err := loadGitVersion(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
atLeastVersion, err := version.NewVersion(equal)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !gitVersion.Equal(atLeastVersion) {
|
||||||
|
return fmt.Errorf("installed git binary version %s is not equal to %s", gitVersion.Original(), equal)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func configSet(key, value string) error {
|
func configSet(key, value string) error {
|
||||||
stdout, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
|
stdout, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
|
||||||
if err != nil && !err.IsExitCode(1) {
|
if err != nil && !err.IsExitCode(1) {
|
||||||
|
|
|
@ -133,7 +133,13 @@ func (c *CheckAttributeReader) Init(ctx context.Context) error {
|
||||||
c.env = append(c.env, "GIT_WORK_TREE="+c.WorkTree)
|
c.env = append(c.env, "GIT_WORK_TREE="+c.WorkTree)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.env = append(c.env, "GIT_FLUSH=1")
|
// Version 2.43.1 has a bug where the behavior of `GIT_FLUSH` is flipped.
|
||||||
|
// Ref: https://lore.kernel.org/git/CABn0oJvg3M_kBW-u=j3QhKnO=6QOzk-YFTgonYw_UvFS1NTX4g@mail.gmail.com
|
||||||
|
if InvertedGitFlushEnv {
|
||||||
|
c.env = append(c.env, "GIT_FLUSH=0")
|
||||||
|
} else {
|
||||||
|
c.env = append(c.env, "GIT_FLUSH=1")
|
||||||
|
}
|
||||||
|
|
||||||
c.cmd.AddDynamicArguments(c.Attributes...)
|
c.cmd.AddDynamicArguments(c.Attributes...)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue