gitea
Зеркало из https://github.com/go-gitea/gitea
/
main.go
60 строк · 1.5 Кб
1// Copyright 2014 The Gogs Authors. All rights reserved.
2// Copyright 2016 The Gitea Authors. All rights reserved.
3// SPDX-License-Identifier: MIT
4
5package main
6
7import (
8"os"
9"runtime"
10"strings"
11"time"
12
13"code.gitea.io/gitea/cmd"
14"code.gitea.io/gitea/modules/log"
15"code.gitea.io/gitea/modules/setting"
16
17// register supported doc types
18_ "code.gitea.io/gitea/modules/markup/asciicast"
19_ "code.gitea.io/gitea/modules/markup/console"
20_ "code.gitea.io/gitea/modules/markup/csv"
21_ "code.gitea.io/gitea/modules/markup/markdown"
22_ "code.gitea.io/gitea/modules/markup/orgmode"
23
24"github.com/urfave/cli/v2"
25)
26
27// these flags will be set by the build flags
28var (
29Version = "development" // program version for this build
30Tags = "" // the Golang build tags
31MakeVersion = "" // "make" program version if built with make
32)
33
34func init() {
35setting.AppVer = Version
36setting.AppBuiltWith = formatBuiltWith()
37setting.AppStartTime = time.Now().UTC()
38}
39
40func main() {
41cli.OsExiter = func(code int) {
42log.GetManager().Close()
43os.Exit(code)
44}
45app := cmd.NewMainApp(cmd.AppVersion{Version: Version, Extra: formatBuiltWith()})
46_ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp
47log.GetManager().Close()
48}
49
50func formatBuiltWith() string {
51version := runtime.Version()
52if len(MakeVersion) > 0 {
53version = MakeVersion + ", " + runtime.Version()
54}
55if len(Tags) == 0 {
56return " built with " + version
57}
58
59return " built with " + version + " : " + strings.ReplaceAll(Tags, " ", ", ")
60}
61