git-mob
Version:
CLI tool for adding co-authors to commits.
10 lines (9 loc) • 1.26 kB
JavaScript
import c from"minimist";import{gitRevParse as l,repoAuthorList as m,saveNewCoAuthors as g}from"git-mob-core";import h from"@inquirer/checkbox";import{stripIndent as u}from"common-tags";import y from"update-notifier";var A=1e3*60*60*24*7;function s(){let o=u`
Usage
$ git suggest-coauthors [author name | author email]
Options
-h Prints usage information
Example
$ git suggest-coauthors # suggests coauthors who have contributed to this repo
$ git suggest-coauthors rich # filter suggested coauthors
`;console.log(o)}var i={red:"\x1B[31m",yellow:"\x1B[33m"},a="\x1B[0m";function r(o){return i.red+o+a}function n(o){return i.yellow+o+a}var p=c(process.argv.slice(2),{alias:{h:"help"}});async function d(o){o.help&&(s(),process.exit(0)),await l.insideWorkTree()||(console.error(r("Error: not a git repository")),process.exit(1)),await f(o._.join(" ")),process.exit(0)}async function f(o){try{let t=await m(o.trim());if(t&&t.length>0){let e=await $(t);e&&await g(e)}else console.log(n("Could not find authors!"))}catch(t){console.error(r(`Error: ${t.message}`)),process.exit(1)}}async function $(o){return await h({message:"Select co-authors to save",choices:o.map(e=>({name:`"${e.name}" ${e.email}`,value:e}))})}await d(p);