Skip to content

Commit

Permalink
adding commit to info
Browse files Browse the repository at this point in the history
  • Loading branch information
rafiki270 committed Oct 16, 2019
1 parent fa26543 commit e2db399
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion Sources/ApiCore/Controllers/SettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation
import Vapor
import ApiCore
import ErrorsCore
import FluentPostgreSQL

Expand Down
17 changes: 16 additions & 1 deletion Sources/ApiCore/Model/Info.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public struct Info: Content {
/// Gitlab teams
public let allowedGitlabGroups: [String]

/// Commit hash (if available, n/a otherwise)
public let commit: String

enum CodingKeys: String, CodingKey {
case allowLogin = "allow_login"
case singleTeam = "single_team"
Expand All @@ -67,6 +70,7 @@ public struct Info: Content {
case allowedGithubTeams = "allowed_github_teams"
case gitlabEnabled = "gitlab_enabled"
case allowedGitlabGroups = "allowed_gitlab_groups"
case commit
}

}
Expand Down Expand Up @@ -104,6 +108,16 @@ public struct Info: Content {
let url = try fm.url(for: "server/image/\($0.rawValue)", on: req)
return Info.Icon(size: $0, url: url)
})

let dc = DirectoryConfig.detect()
let url = URL(fileURLWithPath: dc.workDir).appendingPathComponent("Resources").appendingPathComponent("commit.txt")
let commit: String
if FileManager.default.fileExists(atPath: url.path), let c = try? String(contentsOfFile: url.path) {
commit = c
} else {
commit = "n/a"
}

config = Config(
singleTeam: ApiCoreBase.configuration.general.singleTeam,
allowLogin: ApiCoreBase.configuration.auth.allowLogin,
Expand All @@ -114,7 +128,8 @@ public struct Info: Content {
githubEnabled: ApiCoreBase.configuration.auth.github.enabled,
allowedGithubTeams: ApiCoreBase.configuration.auth.github.teams,
gitlabEnabled: ApiCoreBase.configuration.auth.gitlab.enabled,
allowedGitlabGroups: ApiCoreBase.configuration.auth.gitlab.groups
allowedGitlabGroups: ApiCoreBase.configuration.auth.gitlab.groups,
commit: commit
)
}

Expand Down
1 change: 0 additions & 1 deletion Sources/ApiCore/Model/Setting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Foundation
import Vapor
import Fluent
import FluentPostgreSQL
import ApiCore
import ErrorsCore


Expand Down

0 comments on commit e2db399

Please sign in to comment.