Skip to content

Commit

Permalink
Fix GitLogParser dialogues and docs (#3073)
Browse files Browse the repository at this point in the history
* Change the way the ParserDialogues of the subcommands are called, to catch regressions
#3073

* Fix RepoScanCommand returning the wrong dialogue
#3073

* Update documentation
#3073

* Update documentation to link to anongit
#3078

* Update changelog
#3078
  • Loading branch information
MW-Friedrich committed Oct 7, 2022
1 parent 0c9b57a commit 2d457c9
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 70 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

### Fixed 🐞

- Fix interactive GitLogParser using wrong dialogue with repo-scan subcommand [#3073](https://github.com/MaibornWolff/codecharta/pull/3073)
- Fix CodeCharta Analysis container exiting when detached [#3062](https://github.com/MaibornWolff/codecharta/pull/3062)
- Fix CodeCharta Analysis container not coming with the sonar-scanner pre-installed [#3062](https://github.com/MaibornWolff/codecharta/pull/3062)
- Rerender immediately after marking a folder with a color [#3067](https://github.com/MaibornWolff/codecharta/pull/3067)
Expand Down
62 changes: 29 additions & 33 deletions analysis/import/GitLogParser/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# GitLogParser

Generates visualisation data from git repository logs and repository file list.
Generates visualization data from git repository logs and repository file list.

This parser specializes in tracking file changes across different file-versions on different feature-branches and then the merged main.
Furthermore, special care is taken not to display non-existent files that might show up in normal-Git histories due to renaming actions on feature branches.
This parser specializes in tracking file changes across different file-versions on different feature-branches and then
the merged main.
Furthermore, special care is taken not to display non-existent files that might show up in normal Git histories due to
renaming actions on feature branches.

Things to note:

Expand All @@ -30,46 +32,31 @@ Additionally, the following Edge Metrics are calculated:

The names of authors are saved when the --add-author flag is set.

## Usage
## Scan a local git repository on your machine

### Creating required files on the fly | repo-scan

See `ccsh gitlogparser repo-scan -h` for help. Standard usage:

> `ccsh gitlogparser repo-scan --repo-path <path>`
With the sub command `repo-scan`, the git log and the file name list are created automatically either from the
current working directory or from the directory at `repo-path`.
With the sub command `repo-scan` you can parse a local git repository on your disk. During scanning a git log of the
repository in the current working directory (or from the directory specified by repo-path) is created in your
temp-Folder and parsed automatically. Furthermore, the parser creates another temporary file-name-list of files that are
tracked by git automatically which is needed for the parsing process.

The result is written as JSON to standard out or into an output file (if specified by `-o` option).

If a project is piped into the GitLogParser, the results and the piped project are merged.
The resulting project has the project name specified for the GitLogParser.

#### Example using Git
#### Executing the repo-scan subcommand

- `cd <my_git_project>`
- `./ccsh gitlogparser repo-scan -o output.cc.json`
- load `output.cc.json` in visualization
- `ccsh gitlogparser repo-scan --repo-path <path_to_my_git_project> -o output.cc.json.gz`
- load `output.cc.json.gz` in visualization

### Manual creation of required files | log-scan

#### Creating the repository log for metric generation

| SCM | Log format | Command for log creation | tracks renames | ignores deleted files | supports code churn |
| --- | ---------------------------- | --------------------------------------------------- | -------------- | --------------------- | ------------------- |
| git | GIT_LOG_NUMSTAT_RAW_REVERSED | `git log --numstat --raw --topo-order --reverse -m` | yes | yes | yes |

You can also use the bash script anongit which generates an anonymous git log with log format GIT_LOG for usage with CodeCharta.

#### Creating the git files list of the repository for metric generation

> `git ls-files > file-name-list.txt`
Please make sure to execute this command in the root folder of your repository.

#### Executing the GitLogParser

See `ccsh gitlogparser log-scan -h` for help. Standard usage:

> `ccsh gitlogparser log-scan --git-log <path> --repo-files <path>`
Expand All @@ -81,17 +68,26 @@ The result is written as JSON to standard out or into an output file (if specifi
If a project is piped into the GitLogParser, the results and the piped project are merged.
The resulting project has the project name specified for the GitLogParser.

## Examples
#### Creating the repository log for metric generation

| SCM | Log format | Command for log creation | tracks renames | ignores deleted files | supports code churn |
| --- | ---------------------------- | --------------------------------------------------- | -------------- | --------------------- | ------------------- |
| git | GIT_LOG_NUMSTAT_RAW_REVERSED | `git log --numstat --raw --topo-order --reverse -m` | yes | yes | yes |

You can also use the bash
script [anongit](https://github.com/MaibornWolff/codecharta/blob/main/analysis/import/GitLogParser/src/main/dist/anongit)
which generates a git log with anonymized authors for usage with CodeCharta.

#### Creating the git files list of the repository for metric generation

### Automatic usage
> `git ls-files > file-name-list.txt`
- `./ccsh gitlogparser repo-scan --repo-path <path_to_my_git_project> -o output.cc.json`
- load `output.cc.json` in visualization
Please make sure to execute this command in the root folder of your repository.

### Manual usage
#### Executing the log-scan subcommand

- `cd <my_git_project>`
- `git log --numstat --raw --topo-order --reverse -m > git.log` (or `anongit > git.log`)
- `git ls-files > file-name-list.txt`
- `./ccsh gitlogparser log-scan --git-log git.log --repo-files file-name-list.txt -o output.cc.json`
- load `output.cc.json` in visualization
- `ccsh gitlogparser log-scan --git-log git.log --repo-files file-name-list.txt -o output.cc.json.gz`
- load `output.cc.json.gz` in visualization
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package de.maibornwolff.codecharta.importer.gitlogparser
import com.github.kinquirer.KInquirer
import com.github.kinquirer.components.promptConfirm
import com.github.kinquirer.components.promptInput
import de.maibornwolff.codecharta.importer.gitlogparser.subcommands.LogScanParserDialog
import de.maibornwolff.codecharta.importer.gitlogparser.subcommands.RepoScanParserDialog
import de.maibornwolff.codecharta.importer.gitlogparser.subcommands.LogScanCommand
import de.maibornwolff.codecharta.importer.gitlogparser.subcommands.RepoScanCommand
import de.maibornwolff.codecharta.tools.interactiveparser.ParserDialogInterface

class ParserDialog {
Expand All @@ -24,8 +24,8 @@ class ParserDialog {
}

val subcommandArguments =
if (isLogScan) LogScanParserDialog.collectParserArgs()
else RepoScanParserDialog.collectParserArgs()
if (isLogScan) LogScanCommand().getDialog().collectParserArgs()
else RepoScanCommand().getDialog().collectParserArgs()

val outputFileName: String = KInquirer.promptInput(
message = "What is the name of the output file? If empty, the result will be returned to stdOut",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ class RepoScanCommand : Callable<Void>, InteractiveParser {
return tempGitLs
}

override fun getDialog(): ParserDialogInterface = LogScanParserDialog
override fun getDialog(): ParserDialogInterface = RepoScanParserDialog
}
60 changes: 28 additions & 32 deletions gh-pages/_docs/04-12-gitlogparser.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ title: "Git Log Parser"

Generates visualisation data from git repository logs and repository file list.

This parser specializes in tracking file changes across different file-versions on different feature-branches and then the merged main.
Furthermore, special care is taken not to display non-existent files that might show up in normal-Git histories due to renaming actions on feature branches.
This parser specializes in tracking file changes across different file-versions on different feature-branches and then
the merged main.
Furthermore, special care is taken not to display non-existent files that might show up in normal Git histories due to
renaming actions on feature branches.

Things to note:

Expand All @@ -35,46 +37,31 @@ Additionally, the following Edge Metrics are calculated:

The names of authors are saved when the --add-author flag is set.

## Usage
## Scan a local git repository on your machine

### Creating required files on the fly | repo-scan

See `ccsh gitlogparser repo-scan -h` for help. Standard usage:

> `ccsh gitlogparser repo-scan --repo-path <path>`
With the sub command `repo-scan`, the git log and the file name list are created automatically either from the
current working directory or from the directory at `repo-path`.
With the sub command `repo-scan` you can parse a local git repository on your disk. During scanning a git log of the
repository in the current working directory (or from the directory specified by repo-path) is created in your
temp-Folder and parsed automatically. Furthermore, the parser creates another temporary file-name-list of files that are
tracked by git automatically which is needed for the parsing process.

The result is written as JSON to standard out or into an output file (if specified by `-o` option).

If a project is piped into the GitLogParser, the results and the piped project are merged.
The resulting project has the project name specified for the GitLogParser.

#### Example using Git
#### Executing the repo-scan subcommand

- `cd <my_git_project>`
- `./ccsh gitlogparser repo-scan -o output.cc.json`
- load `output.cc.json` in visualization
- `ccsh gitlogparser repo-scan --repo-path <path_to_my_git_project> -o output.cc.json.gz`
- load `output.cc.json.gz` in visualization

### Manual creation of required files | log-scan

#### Creating the repository log for metric generation

| SCM | Log format | Command for log creation | tracks renames | ignores deleted files | supports code churn |
| --- | ---------------------------- | --------------------------------------------------- | -------------- | --------------------- | ------------------- |
| git | GIT_LOG_NUMSTAT_RAW_REVERSED | `git log --numstat --raw --topo-order --reverse -m` | yes | yes | yes |

You can also use the bash script anongit which generates an anonymous git log with log format GIT_LOG for usage with CodeCharta.

#### Creating the git files list of the repository for metric generation

> `git ls-files > file-name-list.txt`
Please make sure to execute this command in the root folder of your repository.

#### Executing the GitLogParser

See `ccsh gitlogparser log-scan -h` for help. Standard usage:

> `ccsh gitlogparser log-scan --git-log <path> --repo-files <path>`
Expand All @@ -86,17 +73,26 @@ The result is written as JSON to standard out or into an output file (if specifi
If a project is piped into the GitLogParser, the results and the piped project are merged.
The resulting project has the project name specified for the GitLogParser.

## Examples
#### Creating the repository log for metric generation

| SCM | Log format | Command for log creation | tracks renames | ignores deleted files | supports code churn |
| --- | ---------------------------- | --------------------------------------------------- | -------------- | --------------------- | ------------------- |
| git | GIT_LOG_NUMSTAT_RAW_REVERSED | `git log --numstat --raw --topo-order --reverse -m` | yes | yes | yes |

You can also use the bash
script [anongit](https://github.com/MaibornWolff/codecharta/blob/main/analysis/import/GitLogParser/src/main/dist/anongit)
which generates a git log with anonymized authors for usage with CodeCharta.

#### Creating the git files list of the repository for metric generation

### Automatic usage
> `git ls-files > file-name-list.txt`
- `./ccsh gitlogparser repo-scan --repo-path <path_to_my_git_project> -o output.cc.json`
- load `output.cc.json` in visualization
Please make sure to execute this command in the root folder of your repository.

### Manual usage
#### Executing the log-scan subcommand

- `cd <my_git_project>`
- `git log --numstat --raw --topo-order --reverse -m > git.log` (or `anongit > git.log`)
- `git ls-files > file-name-list.txt`
- `./ccsh gitlogparser log-scan --git-log git.log --repo-files file-name-list.txt -o output.cc.json`
- load `output.cc.json` in visualization
- `ccsh gitlogparser log-scan --git-log git.log --repo-files file-name-list.txt -o output.cc.json.gz`
- load `output.cc.json.gz` in visualization

0 comments on commit 2d457c9

Please sign in to comment.