mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-08-18 21:51:30 +02:00
FORGEJO_* environment variables are set to the corresponding GITEA_* variable when the cli starts. This approach is intended to minimize the conflicts on rebase. All occurences of GITEA_* are left untouched in the codebase and they are only changed to FORGEJO_* if exposed to the user. (cherry picked from commite466f9d10e
) (cherry picked from commite33e95931b
) (cherry picked from commit2cfc6519b7
) (cherry picked from commitaf8864373a
) (cherry picked from commita0550ff339
) (cherry picked from commit24dc0a5191
) (cherry picked from commite255eea2b4
) (cherry picked from commit0c4f5afa7a
) (cherry picked from commit42fce708d0
) (cherry picked from commite7278c3c22
) (cherry picked from commit0fb9ed7e0e
) (cherry picked from commita98308aa4d
) (cherry picked from commitb8695fcbe0
) (cherry picked from commit4aee8719f5
) (cherry picked from commit1c503c1ba7
) (cherry picked from commitcf1ed8551e
) (cherry picked from commitc52459b088
) (cherry picked from commit92cac277b2
) (cherry picked from commit2c744f1118
) (cherry picked from commit989a98a8c5
) (cherry picked from commit9cf7052bd4
) (cherry picked from commita13c9667e0
) Conflicts: main.go https://codeberg.org/forgejo/forgejo/pulls/1216 (cherry picked from commita9c3cf060d
) (cherry picked from commiteb6d904b23
) (cherry picked from commitfd4878e487
) (cherry picked from commitcc2cab9241
) (cherry picked from commitbe523c63db
) (cherry picked from commit254d1a2f9a
) (cherry picked from commit1eecf4200e
) (cherry picked from commita01f5c3475
) (cherry picked from commitb1ba7ce321
) (cherry picked from commiteddfd96beb
) (cherry picked from commit7a780758c2
) (cherry picked from commitafb88332dc
) (cherry picked from commitaf0448d000
) (cherry picked from commitbdfdc7e169
) (cherry picked from commit01ba057565
)
73 lines
1.7 KiB
Go
73 lines
1.7 KiB
Go
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
// Copyright 2016 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
"strings"
|
|
"time"
|
|
|
|
"code.gitea.io/gitea/cmd"
|
|
"code.gitea.io/gitea/modules/log"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
// register supported doc types
|
|
_ "code.gitea.io/gitea/modules/markup/asciicast"
|
|
_ "code.gitea.io/gitea/modules/markup/console"
|
|
_ "code.gitea.io/gitea/modules/markup/csv"
|
|
_ "code.gitea.io/gitea/modules/markup/markdown"
|
|
_ "code.gitea.io/gitea/modules/markup/orgmode"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// these flags will be set by the build flags
|
|
var (
|
|
Version = "development" // program version for this build
|
|
Tags = "" // the Golang build tags
|
|
MakeVersion = "" // "make" program version if built with make
|
|
)
|
|
|
|
var ForgejoVersion = "1.0.0"
|
|
|
|
func init() {
|
|
setting.AppVer = Version
|
|
setting.ForgejoVersion = ForgejoVersion
|
|
setting.AppBuiltWith = formatBuiltWith()
|
|
setting.AppStartTime = time.Now().UTC()
|
|
}
|
|
|
|
func forgejoEnv() {
|
|
for _, k := range []string{"CUSTOM", "WORK_DIR"} {
|
|
if v, ok := os.LookupEnv("FORGEJO_" + k); ok {
|
|
os.Setenv("GITEA_"+k, v)
|
|
}
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
forgejoEnv()
|
|
cli.OsExiter = func(code int) {
|
|
log.GetManager().Close()
|
|
os.Exit(code)
|
|
}
|
|
app := cmd.NewMainApp(Version, formatBuiltWith())
|
|
_ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp
|
|
log.GetManager().Close()
|
|
}
|
|
|
|
func formatBuiltWith() string {
|
|
version := runtime.Version()
|
|
if len(MakeVersion) > 0 {
|
|
version = MakeVersion + ", " + runtime.Version()
|
|
}
|
|
if len(Tags) == 0 {
|
|
return " built with " + version
|
|
}
|
|
|
|
return " built with " + version + " : " + strings.ReplaceAll(Tags, " ", ", ")
|
|
}
|