aboutsummaryrefslogtreecommitdiffstats
path: root/prog/meta.go
blob: 3524963c0e16e1de923dc7ce76e25a1e1d51da30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2020 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package prog

import (
	"strings"
	"time"
)

const defaultGitRevision = "unknown"

var (
	GitRevision     = defaultGitRevision // emitted by Makefile, may contain + at the end
	GitRevisionBase string               // without +
	gitRevisionDate string               // emitted by Makefile
	GitRevisionDate time.Time            // parsed from gitRevisionDate
)

func GitRevisionKnown() bool {
	return GitRevision != defaultGitRevision
}

func init() {
	GitRevisionBase = strings.ReplaceAll(GitRevision, "+", "")
	if gitRevisionDate != "" {
		var err error
		if GitRevisionDate, err = time.Parse("20060102-150405", gitRevisionDate); err != nil {
			panic(err)
		}
	}
}