Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git branch info #130

Open
gloriaJun opened this issue Sep 13, 2021 · 0 comments
Open

git branch info #130

gloriaJun opened this issue Sep 13, 2021 · 0 comments
Assignees

Comments

@gloriaJun
Copy link
Owner

const proc = require('child_process');

function getGitInfo(cmd) {
  return proc.execSync(cmd).toString().trim();
}

// 현재 브랜치
const branch = getGitInfo("git branch | grep \\* | cut -d ' ' -f2-");
// 마지막 커밋의 Hash
const lastCommitLog = getGitInfo(
  `git log --date=short --pretty=format:'%h%Creset %s (%cd) <%an>%Creset' --abbrev-commit | head -n 1`
);
// 마지막 커밋의 날짜
const lastCommitDate = getGitInfo(`git log --date=short --pretty=tformat:%cd -1`);
// 마지막 커밋의 Hash
const lastCommitHash = getGitInfo(`git log --pretty=tformat:%h -1`);

module.exports = {
  // filename: date + '-' + hash,
  branch,
  lastCommitLog,
  lastCommitDate,
  lastCommitHash,
};
@gloriaJun gloriaJun self-assigned this Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant