admin: Display commit ID in admin interface
This commit is contained in:
parent
92bb409764
commit
2645109839
9 changed files with 30 additions and 5 deletions
|
|
@ -19,6 +19,8 @@ import (
|
|||
type Importer interface {
|
||||
// Kind returns information about the Importer, for human interrest.
|
||||
Kind() string
|
||||
// Id returns information about the current state (commit id, ...).
|
||||
Id() *string
|
||||
// init performs the importer initialization.
|
||||
Init() error
|
||||
// sync tries to pull the latest modification of the underlying storage.
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ func SpeedySyncDeep(i Importer) (errs map[string][]string) {
|
|||
|
||||
if err := i.Sync(); err != nil {
|
||||
errs["_sync"] = []string{err.Error()}
|
||||
if _id := i.Id(); _id != nil {
|
||||
errs["_sync"] = append(errs["_sync"], *_id)
|
||||
}
|
||||
}
|
||||
|
||||
errs["_date"] = []string{fmt.Sprintf("%v", startTime)}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ func (i CloudImporter) Kind() string {
|
|||
return "cloud file importer: " + i.baseDAV.String()
|
||||
}
|
||||
|
||||
func (i CloudImporter) Id() *string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i CloudImporter) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func NewGitImporter(li LocalImporter, remote string) GitImporter {
|
|||
}
|
||||
}
|
||||
|
||||
func (i GitImporter) Kind() string {
|
||||
func (i GitImporter) Id() *string {
|
||||
var gitinfo string
|
||||
r, err := git.PlainOpen(i.li.Base)
|
||||
if err == nil {
|
||||
|
|
@ -61,7 +61,7 @@ func (i GitImporter) Kind() string {
|
|||
}
|
||||
}
|
||||
|
||||
return "git originated from " + i.Remote + " on " + i.li.Kind() + ", currently on commit " + gitinfo
|
||||
return &gitinfo
|
||||
}
|
||||
|
||||
func (i GitImporter) Init() error {
|
||||
|
|
|
|||
|
|
@ -37,3 +37,7 @@ func (i GitImporter) listDir(filename string) ([]string, error) {
|
|||
func (i GitImporter) stat(filename string) (os.FileInfo, error) {
|
||||
return i.li.stat(filename)
|
||||
}
|
||||
|
||||
func (i GitImporter) Kind() string {
|
||||
return "git originated from " + i.Remote + " on " + i.li.Kind()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func NewGitImporter(li LocalImporter, remote string) GitImporter {
|
|||
}
|
||||
}
|
||||
|
||||
func (i GitImporter) Kind() string {
|
||||
func (i GitImporter) Id() *string {
|
||||
cmdshow := exec.Command("git", "-C", i.li.Base, "show")
|
||||
var outshow bytes.Buffer
|
||||
cmdshow.Stdout = &outshow
|
||||
|
|
@ -43,7 +43,7 @@ func (i GitImporter) Kind() string {
|
|||
}
|
||||
}
|
||||
|
||||
return "git originated from " + i.Remote + " on " + i.li.Kind() + ", currently on commit " + commit
|
||||
return &commit
|
||||
}
|
||||
|
||||
func (i GitImporter) Init() error {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ func (i LocalImporter) Kind() string {
|
|||
}
|
||||
}
|
||||
|
||||
func (i LocalImporter) Id() *string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i LocalImporter) Init() error {
|
||||
if f, err := os.Stat(i.Base); os.IsNotExist(err) {
|
||||
if err = os.Mkdir(i.Base, 0751); err != nil {
|
||||
|
|
|
|||
Reference in a new issue