Skip to content

Commit

Permalink
Fixes #21, add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
abskmj committed Nov 1, 2020
1 parent f2ab58c commit 255661b
Show file tree
Hide file tree
Showing 5 changed files with 2,148 additions and 50 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
.hukumrc
.hukumrc
.nyc_output
coverage
17 changes: 9 additions & 8 deletions lib/git.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

const git = require('simple-git')()
exports.git = require('simple-git')()

exports.getRepo = async () => {
const remotes = await exports.git.getRemotes(true)

const getRepo = async () => {
const remotes = await git.getRemotes(true)
const gh = remotes.find((remote) => remote.refs.push.includes('github.com'))

const regexp = RegExp(/github.com[/:](.*?)\/(.*?)\.git$/)
const regexp = RegExp(/github.com[/:](.*?)\/(.*?)(\.git$|$)/)

const matches = regexp.exec(gh.refs.push)

Expand All @@ -14,18 +15,18 @@ const getRepo = async () => {
}
}

module.exports.getInfo = async () => {
exports.getInfo = async () => {
const info = {}

const status = await git.status()
const status = await exports.git.status()
info.branch = status.current

const log = await git.log()
const log = await exports.git.log()

info.hash = log.latest.hash
info.author = log.latest.author_email

info.repo = await getRepo()
info.repo = await exports.getRepo()

console.log(info)

Expand Down
Loading

0 comments on commit 255661b

Please sign in to comment.