-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change. Allows use environment variables for information about repo.
- Loading branch information
Showing
4 changed files
with
147 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
local GitRepo = require"luacov.coveralls.GitRepo" | ||
local ci = require"luacov.coveralls.CiInfo" | ||
|
||
local function try_any_repo(repo_path) | ||
-- currenly support only git | ||
local repo, err = GitRepo:new(repo_path) | ||
if repo then return repo, "git" end | ||
|
||
-- @todo warning message about failure | ||
|
||
local function dummy() end | ||
return setmetatable({}, {__index = function() return dummy end}), "unknown" | ||
end | ||
|
||
----------------------------------------------------------- | ||
local CiRepoInfo = {} do | ||
CiRepoInfo.__index = CiRepoInfo | ||
|
||
function CiRepoInfo:new(repo_path) | ||
local repo, type = try_any_repo(repo_path) | ||
local o = setmetatable({ | ||
_repo = assert(repo); | ||
_repo_type = assert(type); | ||
}, self) | ||
|
||
return o | ||
end | ||
|
||
CiRepoInfo.type = function(self) return self._repo_type end | ||
|
||
CiRepoInfo.path = function(self) return self._repo:path() end | ||
CiRepoInfo.version = function(self) return self._repo:version() end | ||
|
||
CiRepoInfo.id = function(self) return self._repo:id() or ci.commit_id() end | ||
CiRepoInfo.last_author_name = function(self) return self._repo:last_author_name() or ci.author_name() end | ||
CiRepoInfo.last_author_email = function(self) return self._repo:last_author_email() or ci.author_email() end | ||
CiRepoInfo.last_committer_name = function(self) return self._repo:last_committer_name() or ci.committer_name() end | ||
CiRepoInfo.last_committer_email = function(self) return self._repo:last_committer_email() or ci.committer_email() end | ||
CiRepoInfo.last_message = function(self) return self._repo:last_message() or ci.message() end | ||
CiRepoInfo.current_branch = function(self) return self._repo:current_branch() or ci.branch() end | ||
CiRepoInfo.remotes = function(self) return self._repo:remotes() end | ||
|
||
end | ||
----------------------------------------------------------- | ||
|
||
return CiRepoInfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters