Skip to content

Commit

Permalink
Fix. remove newline from git version string.
Browse files Browse the repository at this point in the history
  • Loading branch information
moteus committed Sep 24, 2014
1 parent 61c4103 commit 79dcb1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/luacov/coveralls/GitRepo.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
local utils = require "luacov.coveralls.utils"local path = require "path"local exec = utils.execlocal function git_exec(cwd, ...) local ok, status, msg = exec(cwd, 'git', ...) if not ok then return ok, msg or status end return msg or ''endlocal function git_version() return git_exec('.', '--version')endlocal function git_last_log(cwd, fmt) return git_exec(cwd, '--no-pager log -1 --pretty=format:%s', fmt)endlocal function make_git_log_getter(fmt) return function(cwd) return git_last_log(cwd, fmt) endendlocal git_id = make_git_log_getter'%H'local git_last_author_name = make_git_log_getter'%aN'local git_last_author_email = make_git_log_getter'%ae'local git_last_committer_name = make_git_log_getter'%cN'local git_last_committer_email = make_git_log_getter'%ce'local git_last_message = make_git_log_getter'%s'local git_current_branch = function (cwd) local str, err = git_exec(cwd, 'rev-parse --abbrev-ref HEAD') if not str then return nil, err end return (str:match("^%s*(%S+)"))endlocal git_remotes = function (cwd) local str, err = git_exec(cwd, 'remote -v') if not str then return nil, err end local res = {} str:gsub("%s*(%S+)%s+([^\n\r]+)%((%a+)%)%s*\r?\n", function(name, url, mode) if mode == 'fetch' then res[name] = url end end) return resend-----------------------------------------------------------local GitRepoInfo = {} doGitRepoInfo.__index = GitRepoInfofunction GitRepoInfo:new(repo_path) repo_path = path.fullpath(repo_path) if not path.isdir(repo_path) then return nil, 'git rep does not exists' end local ver, err = git_version() if not ver then return nil, err end local o = setmetatable({ _path = repo_path }, self) return oendGitRepoInfo.path = function(self) return self._path endGitRepoInfo.version = function(self) return git_version () endGitRepoInfo.id = function(self) return git_id (self:path()) endGitRepoInfo.last_author_name = function(self) return git_last_author_name (self:path()) endGitRepoInfo.last_author_email = function(self) return git_last_author_email (self:path()) endGitRepoInfo.last_committer_name = function(self) return git_last_committer_name (self:path()) endGitRepoInfo.last_committer_email = function(self) return git_last_committer_email (self:path()) endGitRepoInfo.last_message = function(self) return git_last_message (self:path()) endGitRepoInfo.current_branch = function(self) return git_current_branch (self:path()) endGitRepoInfo.remotes = function(self) return git_remotes (self:path()) endend-----------------------------------------------------------return GitRepoInfo
local utils = require "luacov.coveralls.utils"local path = require "path"local exec = utils.execlocal function git_exec(cwd, ...) local ok, status, msg = exec(cwd, 'git', ...) if not ok then return ok, msg or status end return msg or ''endlocal function git_version() local ver, err = git_exec('.', '--version') if not ver then return nil, err end return (ver:gsub("%s+$", ""))endlocal function git_last_log(cwd, fmt) return git_exec(cwd, '--no-pager log -1 --pretty=format:%s', fmt)endlocal function make_git_log_getter(fmt) return function(cwd) return git_last_log(cwd, fmt) endendlocal git_id = make_git_log_getter'%H'local git_last_author_name = make_git_log_getter'%aN'local git_last_author_email = make_git_log_getter'%ae'local git_last_committer_name = make_git_log_getter'%cN'local git_last_committer_email = make_git_log_getter'%ce'local git_last_message = make_git_log_getter'%s'local git_current_branch = function (cwd) local str, err = git_exec(cwd, 'rev-parse --abbrev-ref HEAD') if not str then return nil, err end return (str:match("^%s*(%S+)"))endlocal git_remotes = function (cwd) local str, err = git_exec(cwd, 'remote -v') if not str then return nil, err end local res = {} str:gsub("%s*(%S+)%s+([^\n\r]+)%((%a+)%)%s*\r?\n", function(name, url, mode) if mode == 'fetch' then res[name] = url end end) return resend-----------------------------------------------------------local GitRepoInfo = {} doGitRepoInfo.__index = GitRepoInfofunction GitRepoInfo:new(repo_path) repo_path = path.fullpath(repo_path) if not path.isdir(repo_path) then return nil, 'git rep does not exists' end local ver, err = git_version() if not ver then return nil, err end local o = setmetatable({ _path = repo_path }, self) return oendGitRepoInfo.path = function(self) return self._path endGitRepoInfo.version = function(self) return git_version () endGitRepoInfo.id = function(self) return git_id (self:path()) endGitRepoInfo.last_author_name = function(self) return git_last_author_name (self:path()) endGitRepoInfo.last_author_email = function(self) return git_last_author_email (self:path()) endGitRepoInfo.last_committer_name = function(self) return git_last_committer_name (self:path()) endGitRepoInfo.last_committer_email = function(self) return git_last_committer_email (self:path()) endGitRepoInfo.last_message = function(self) return git_last_message (self:path()) endGitRepoInfo.current_branch = function(self) return git_current_branch (self:path()) endGitRepoInfo.remotes = function(self) return git_remotes (self:path()) endend-----------------------------------------------------------return GitRepoInfo
Expand Down

0 comments on commit 79dcb1b

Please sign in to comment.