Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

last-commit-log

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

last-commit-log - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

38

index.js
'use strict'
const gitRemoteOriginUrl = require('git-remote-origin-url')
const promisify = require('util').promisify
const exec = promisify(require('child_process').exec)

@@ -11,4 +13,2 @@ module.exports = class LCL {

async getLastCommit () {
const promisify = require('util').promisify
const exec = promisify(require('child_process').exec)
const prettyFormat = [

@@ -30,8 +30,4 @@ '%h', '%H', '%s', '%f', '%b',

c = stdout.split(splitCharacter)
const { stdout: revParseBranch } = await exec('git rev-parse --abbrev-ref HEAD', opts)
const { stdout: nameRevBranch } = await exec('git name-rev --name-only HEAD', opts)
gitBranch = await getGitBranch(opts)
const { stdout: tag } = await exec('git tag --contains HEAD', opts)
const branch1 = revParseBranch.trim()
const branch2 = nameRevBranch.trim().replace('remotes/origin/', '')
gitBranch = branch1 === 'HEAD' ? branch2 : branch1
gitTag = tag.trim()

@@ -84,1 +80,29 @@ gitRemote = await gitRemoteOriginUrl(this.cwd)

}
async function getGitBranch (opts = {}) {
let _branch = ''
const [
{ stdout: revParseBranch },
{ stdout: nameRevBranch },
{ stdout: gitLogBranch }
] = await Promise.all([
exec('git rev-parse --abbrev-ref HEAD', opts),
exec('git name-rev --name-only HEAD', opts),
exec('git log -n 1 --pretty=%d HEAD', opts)
])
const branch1 = revParseBranch.trim()
const branch2 = nameRevBranch.trim().replace('remotes/origin/', '')
const branch3 = gitLogBranch.split(',')
.filter(i => i.includes('origin/'))
.map(i => i.trim())
.map(i => i.split('/')[1])
.map(i => i.replace(/[()]/, ''))
.filter(i => i !== 'HEAD')
_branch = branch1 !== 'HEAD'
? branch1
: !branch2.startsWith('tags/')
? branch2 : branch3.length > 1
? branch3.filter(i => i !== 'master')[0] : branch3[0]
return _branch
}

2

package.json
{
"name": "last-commit-log",
"version": "1.0.7",
"version": "1.0.8",
"description": "read git last commit log",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc