- gitgrep2csv
- Usage
- Interface: Config
- Interface: GitBlame
- Interface: GitBlameBase
- Interface: GitMerge
- Interface: Match
- API
gitgrep2csv
Turn grep results into a csv with git information on that file / commit
Usage
$ grep -n foo | gitgrep2csv
Interface: Config
Configuration for a run
Properties
appEnv
• Optional
appEnv: string
Defined in
appName
• appName: string
Defined in
input
• Optional
input: any
Defined in
loadDotEnv
• Optional
loadDotEnv: boolean
| Function
Defined in
markdown
• markdown: boolean
Defined in
multilineSep
• Optional
multilineSep: null
| string
| RegExp
Defined in
process
• Optional
process: any
Defined in
semgrep
• semgrep: boolean
Defined in
sep
• sep: string
Defined in
Interface: GitBlame
A single commit & single file's parsed Git Blame
Hierarchy
-
↳
GitBlame
Properties
author
• author: string
Git author of this blame.
Inherited from
Defined in
authorEmail
• authorEmail: string
Git author email of this blame.
Inherited from
Defined in
authorTime
• authorTime: Date
Author time of this blame.
Inherited from
Defined in
authorTz
• Optional
authorTz: number
Timezone of author date
Defined in
committer
• committer: string
Committer name of this blame.
Inherited from
Defined in
committerEmail
• committerEmail: string
Committer email of this blame.
Inherited from
Defined in
committerTime
• committerTime: Date
Committer time of this blame.
Inherited from
Defined in
committerTz
• Optional
committerTz: number
Timezone of committer date
Defined in
lines
• Optional
lines: number
[]
Lines of file this blame applies to
Defined in
previous
• Optional
previous: string
Previous sha of this blame.
Inherited from
Defined in
rev
• rev: string
revision-sha of this blame.
Inherited from
Defined in
summary
• summary: string
Summary text for this blame.
Inherited from
Defined in
Interface: GitBlameBase
Common "blame" information shared by either a line-by-line style git-blame, or by a merge commit.
Hierarchy
Properties
author
• author: string
Git author of this blame.
Defined in
authorEmail
• authorEmail: string
Git author email of this blame.
Defined in
authorTime
• authorTime: Date
Author time of this blame.
Defined in
committer
• committer: string
Committer name of this blame.
Defined in
committerEmail
• committerEmail: string
Committer email of this blame.
Defined in
committerTime
• committerTime: Date
Committer time of this blame.
Defined in
previous
• Optional
previous: string
Previous sha of this blame.
Defined in
rev
• rev: string
revision-sha of this blame.
Defined in
summary
• summary: string
Summary text for this blame.
Defined in
Interface: GitMerge
Blame information for a git merge, typically parsed from Github format PR messages.
Hierarchy
-
↳
GitMerge
Properties
author
• author: string
Git author of this blame.
Inherited from
Defined in
authorEmail
• authorEmail: string
Git author email of this blame.
Inherited from
Defined in
authorTime
• authorTime: Date
Author time of this blame.
Inherited from
Defined in
branch
• Optional
branch: string
Branch name, parsed from summary.
Defined in
committer
• committer: string
Committer name of this blame.
Inherited from
Defined in
committerEmail
• committerEmail: string
Committer email of this blame.
Inherited from
Defined in
committerTime
• committerTime: Date
Committer time of this blame.
Inherited from
Defined in
parent
• parent: string
[]
The parent commits for this merge
Defined in
pr
• Optional
pr: number
Pull request number, parsed from summary.
Defined in
previous
• Optional
previous: string
Previous sha of this blame.
Inherited from
Defined in
rev
• rev: string
revision-sha of this blame.
Inherited from
Defined in
summary
• summary: string
Summary text for this blame.
Inherited from
Defined in
Interface: Match
A grep match. Listed vaguely in order of display in csv,
Properties
commits
• Optional
commits: Record
<string
, GitBlame
>
All commits found for this match, by sha.
Defined in
head
• head: string
Current rev this project is on.
Defined in
lineEnd
• lineEnd: number
Line where this match ends.
Defined in
lineStart
• lineStart: number
Line where this match starts.
Defined in
matchedPath
• matchedPath: string
Path that grep found for this match.
Defined in
matches
• Optional
matches: number
[]
List of exact line numbers where there is a match. Since lineStart & lineEnd might include --before, --after, --context grep context.
Defined in
merges
• Optional
merges: Record
<string
, GitMerge
>
All prs found for this match, by sha.
Defined in
path
• path: string
Path of file inside the project for this match.
Defined in
project
• project: string
Project directory name for this match.
Defined in
rootDir
• rootDir: string
Directory where we found this project
Defined in
text
• text: string
Text of this match.
Defined in
vars
• Optional
vars: Record
<string
, string
>
Any free-variables captured by semgrep.
Defined in
API
Interfaces
Variables
appName
• appName: string
= "gitgrep"
Assign a name, primarily to use for env variable prefix
Defined in
headerTitles
• Const
headerTitles: string
[]
Defined in
helper
• Const
helper: Object
Type declaration
Name | Type |
---|---|
streams |
__module |
Defined in
initialDefaults
• Const
initialDefaults: Readonly
<Config
>
For reference, a copy of the startup defaults
Defined in
input
• input: ReadInput
| undefined
= "-"
Source to read. Defaults to -
for stdin.
Defined in
loadDotEnv
• loadDotEnv: boolean
| Function
Whether to load dotenv or a function to load it
Defined in
markdown
• markdown: boolean
= false
Whether to output in markdown
Defined in
multilineSep
• multilineSep: string
= ""
Seperator for multi-line code blocks
Defined in
semgrep
• semgrep: boolean
= false
Expect semgrep json input
Defined in
sep
• sep: string
= "\t"
Separator for output csv
Defined in
Functions
argsConfig
▸ argsConfig(args?
, base?
): Config
Get config from args & env
Parameters
Name | Type | Default value |
---|---|---|
args |
string [] |
[] |
base |
Partial <Config > |
undefined |
Returns
Defined in
csv
▸ csv(c
): (source
: AsyncIterable
<Match
>) => AsyncGenerator
<string
, void
, unknown
>
Extra & write csv data
Parameters
Name | Type |
---|---|
c |
Config |
Returns
fn
▸ (source
): AsyncGenerator
<string
, void
, unknown
>
Parameters
Name | Type |
---|---|
source |
AsyncIterable <Match > |
Returns
AsyncGenerator
<string
, void
, unknown
>
Defined in
defaults
▸ defaults(base?
): Config
Populate a Config with defaults.
Parameters
Name | Type |
---|---|
base? |
Partial <Config > |
Returns
Defined in
gitBlame
▸ gitBlame(source
): AsyncIterable
<Partial
<Match
>>
Parameters
Name | Type |
---|---|
source |
AsyncIterable <Partial <Match >> |
Returns
AsyncIterable
<Partial
<Match
>>
Defined in
gitHead
▸ gitHead(): (source
: AsyncIterable
<Partial
<Match
>>) => AsyncGenerator
<Partial
<Match
>, void
, unknown
>
Attach the sha of main branch
Returns
fn
▸ (source
): AsyncGenerator
<Partial
<Match
>, void
, unknown
>
Parameters
Name | Type |
---|---|
source |
AsyncIterable <Partial <Match >> |
Returns
AsyncGenerator
<Partial
<Match
>, void
, unknown
>
Defined in
gitProject
▸ gitProject(source
): AsyncIterable
<Partial
<Match
>>
Parameters
Name | Type |
---|---|
source |
AsyncIterable <Partial <Match >> |
Returns
AsyncIterable
<Partial
<Match
>>
Defined in
githubPr
▸ githubPr(source
): AsyncIterable
<Partial
<Match
>>
Parameters
Name | Type |
---|---|
source |
AsyncIterable <Partial <Match >> |
Returns
AsyncIterable
<Partial
<Match
>>
Defined in
lines
▸ lines(source
, split?
): AsyncGenerator
<string
, void
, unknown
>
Process an async-iterator of strings, splitting it on newlines
Parameters
Name | Type | Default value |
---|---|---|
source |
AsyncIterable <string > |
undefined |
split |
RegExp |
newlines |
Returns
AsyncGenerator
<string
, void
, unknown
>
Defined in
loadDotEnvOnce
▸ loadDotEnvOnce(): void
Default strategy to load dotenv first time only.
Returns
void
Defined in
md
▸ md(c
): (source
: AsyncIterable
<Match
>) => AsyncGenerator
<string
, void
, unknown
>
Parameters
Name | Type |
---|---|
c |
Config |
Returns
fn
▸ (source
): AsyncGenerator
<string
, void
, unknown
>
Parameters
Name | Type |
---|---|
source |
AsyncIterable <Match > |
Returns
AsyncGenerator
<string
, void
, unknown
>
Defined in
multilineGroup
▸ multilineGroup(c
): <I>(source
: I
) => I
| (lines
: AsyncIterable
<string
>) => AsyncGenerator
<string
[], void
, unknown
>
Batch lines together until a config.multilineSep appears Or pass through if no multilineSep configured
Parameters
Name | Type |
---|---|
c |
Config |
Returns
<I>(source
: I
) => I
| (lines
: AsyncIterable
<string
>) => AsyncGenerator
<string
[], void
, unknown
>
Defined in
parse
▸ parse(c
): (source
: AsyncIterable
<string
| string
[]>) => AsyncIterable
<Partial
<Match
>>
Parameters
Name | Type |
---|---|
c |
Config |
Returns
fn
▸ (source
): AsyncIterable
<Partial
<Match
>>
Parameters
Name | Type |
---|---|
source |
AsyncIterable <string | string []> |
Returns
AsyncIterable
<Partial
<Match
>>
Defined in
parseSemgrep
▸ parseSemgrep(source
): AsyncGenerator
<Partial
<Match
>, void
, unknown
>
Parameters
Name | Type |
---|---|
source |
AsyncIterable <string > |
Returns
AsyncGenerator
<Partial
<Match
>, void
, unknown
>
Defined in
parseSemgrepMatch
▸ parseSemgrepMatch(semgrep
): Promise
<Partial
<Match
>>
Parse semgrep json input lines
Parameters
Name | Type |
---|---|
semgrep |
Record <string , any > |
Returns
Promise
<Partial
<Match
>>
Defined in
processConfig
▸ processConfig(p?
, c?
): Config
Parameters
Name | Type | Default value |
---|---|---|
p |
Process |
process |
c? |
Partial <Config > |
undefined |
Returns
Defined in
reloadDotEnv
▸ reloadDotEnv(): void
Strategy for always reloading dotenv. Can be useful if config might change & wants freshened.
Returns
void
Defined in
tabsToSpaces
▸ tabsToSpaces(source
): AsyncIterable
<string
>
Parameters
Name | Type |
---|---|
source |
AsyncIterable <string > |
Returns
AsyncIterable
<string
>
Defined in
tabsToSpacesTransform
▸ tabsToSpacesTransform(m
): string
Parameters
Name | Type |
---|---|
m |
string |
Returns
string