Merge branch 'staging' of https://scm.wyattjmiller.com/wymiller/DrillSergeant into staging
This commit is contained in:
commit
895f322bd6
43
DAL/PdfDataService.cs
Normal file
43
DAL/PdfDataService.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using PdfSharpCore.Drawing;
|
||||||
|
using PdfSharpCore.Pdf;
|
||||||
|
|
||||||
|
public class PdfDataService : IDataService
|
||||||
|
{
|
||||||
|
private string _fileName;
|
||||||
|
private string _pathName;
|
||||||
|
private string _dateTime;
|
||||||
|
|
||||||
|
public PdfDataService()
|
||||||
|
{
|
||||||
|
_dateTime = DateTime.Now.ToString("yyyyMMddhhmm");
|
||||||
|
_fileName = $"CommitReport-{_dateTime}.pdf";
|
||||||
|
_pathName = Directory.GetCurrentDirectory() + "/" + _fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteAll(SortedList<string, int> dictResults)
|
||||||
|
{
|
||||||
|
// sort the dictionary passed in
|
||||||
|
var sortedResults = dictResults.OrderByDescending(d => d.Value).ToList();
|
||||||
|
|
||||||
|
// setting the created document
|
||||||
|
var document = new PdfDocument();
|
||||||
|
var page = document.AddPage();
|
||||||
|
|
||||||
|
// heading
|
||||||
|
var gfx = XGraphics.FromPdfPage(page);
|
||||||
|
var fontHeading = new XFont("Times New Roman", 36, XFontStyle.Underline);
|
||||||
|
gfx.DrawString("Commit Report", fontHeading, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.TopCenter);
|
||||||
|
|
||||||
|
// details
|
||||||
|
var fontDetails = new XFont("Times New Roman", 16, XFontStyle.Regular);
|
||||||
|
int positionValue = 50;
|
||||||
|
|
||||||
|
foreach (var i in sortedResults)
|
||||||
|
{
|
||||||
|
gfx.DrawString($"{i.Key}: {i.Value}", fontDetails, XBrushes.Black, new XRect(0, positionValue, page.Width, page.Width), XStringFormats.TopCenter);
|
||||||
|
positionValue += 25;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.Save(_fileName);
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@
|
|||||||
<PackageReference Include="Libgit2sharp" Version="0.27.0-preview-0182" />
|
<PackageReference Include="Libgit2sharp" Version="0.27.0-preview-0182" />
|
||||||
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="2.0.315-alpha.0.9" />
|
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="2.0.315-alpha.0.9" />
|
||||||
<PackageReference Include="Pastel" Version="3.0.1" />
|
<PackageReference Include="Pastel" Version="3.0.1" />
|
||||||
|
<PackageReference Include="PdfSharpCore" Version="1.3.32" />
|
||||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
18
Program.cs
18
Program.cs
@ -7,7 +7,7 @@ static class Program
|
|||||||
var outputOption = new Option<string>(
|
var outputOption = new Option<string>(
|
||||||
"--output",
|
"--output",
|
||||||
"Specify the output given to the user"
|
"Specify the output given to the user"
|
||||||
).FromAmong("stdout", "xlsx");
|
).FromAmong("stdout", "xlsx", "pdf");
|
||||||
outputOption.AddAlias("-o");
|
outputOption.AddAlias("-o");
|
||||||
|
|
||||||
var branchOption = new Option<string>(
|
var branchOption = new Option<string>(
|
||||||
@ -84,6 +84,22 @@ static class Program
|
|||||||
dataAccessExcelCase.WriteData(commits.CommitDetails);
|
dataAccessExcelCase.WriteData(commits.CommitDetails);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "pdf":
|
||||||
|
PdfDataService pdfDataService = new PdfDataService();
|
||||||
|
DataAccess dataAccessPdfCase = new DataAccess(pdfDataService);
|
||||||
|
|
||||||
|
switch (branchOptionValue)
|
||||||
|
{
|
||||||
|
case null:
|
||||||
|
commits.GetCurrentCommitsByName();
|
||||||
|
dataAccessPdfCase.WriteData(commits.CommitDetails);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
commits.GetCommitsByBranch(branchOptionValue);
|
||||||
|
dataAccessPdfCase.WriteData(commits.CommitDetails);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case null:
|
case null:
|
||||||
StdOutDataService stdOutDataService = new StdOutDataService();
|
StdOutDataService stdOutDataService = new StdOutDataService();
|
||||||
DataAccess dataAccessNullCase = new DataAccess(stdOutDataService);
|
DataAccess dataAccessNullCase = new DataAccess(stdOutDataService);
|
||||||
|
71
README.md
71
README.md
@ -9,6 +9,7 @@ Licensed by the Mozilla Public License v2.0 (see [LICENSE](./LICENSE.md))
|
|||||||
###### Table of Contents
|
###### Table of Contents
|
||||||
|
|
||||||
- [Overview](#overview)
|
- [Overview](#overview)
|
||||||
|
- [Usage](#usage)
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
- [Release](#release)
|
- [Release](#release)
|
||||||
- [Source](#source)
|
- [Source](#source)
|
||||||
@ -24,17 +25,65 @@ Licensed by the Mozilla Public License v2.0 (see [LICENSE](./LICENSE.md))
|
|||||||
|
|
||||||
When I was in university, I wanted a program that would tally up my git commits in a certain project that I'm working on. Based on search engine ninja skills, I couldn't find a program that did this. I decided to scratch my own itch.
|
When I was in university, I wanted a program that would tally up my git commits in a certain project that I'm working on. Based on search engine ninja skills, I couldn't find a program that did this. I decided to scratch my own itch.
|
||||||
|
|
||||||
I present DrillSergeant, where you can get a tally of the contributors' commits in a certain project. Additionally, you can filter by branch to get commits by branch.
|
I present DrillSergeant. This is a command-line application to tally up commits, ordered by commit count per contributor. In other words, DrillSergeant orders the contributors by how many commits they have made in descending order. For example, the first contributor listed will have the most commits in the project. The second contributor will have the second most commits, and so on.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Please see the wiki for information.
|
To use this command-line application, you must be in a git project. Otherwise, a nasty error will appear and you won't get your report. You can filter by branch or by tag (cannot be both, another nasty error appears here). You can get your report in your terminal, in a spreadsheet, or a PDF.
|
||||||
|
|
||||||
|
### Command-line arguments
|
||||||
|
|
||||||
|
```bash
|
||||||
|
-o, --output <pdf|stdout|xlsx> Specify the output given to the user
|
||||||
|
-b, --branch <branch> Specify the branch to filter by
|
||||||
|
-t, --tag <tag> Specify the tag to filter by
|
||||||
|
```
|
||||||
|
|
||||||
|
Throw the `-h` flag for quick assistance. Throw the `--version` flag for version information.
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
To get a commit report to your terminal:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
drillsergeant -o stdout
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you can simply:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
drillsergeant
|
||||||
|
```
|
||||||
|
|
||||||
|
To get a commit report to your terminal filtered by the `devel` branch:
|
||||||
|
|
||||||
|
```
|
||||||
|
drillsergeant -b devel
|
||||||
|
```
|
||||||
|
|
||||||
|
To get a commit report to a spreadsheet:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
drillsergeant -o xlsx
|
||||||
|
```
|
||||||
|
|
||||||
|
To get a commit report to a PDF file filtered by the `devel` branch:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
drillsergeant -o pdf -b devel
|
||||||
|
```
|
||||||
|
|
||||||
|
Got too many contributors to fit onto your terminal? Run this by installing [bat](https://github.com/sharkdp/bat):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
drillsergeant | bat
|
||||||
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
There's are two forms of installation: releases and building from sources. This readme goes through both.
|
There's are two forms of installation: releases and building from sources. This readme goes through both.
|
||||||
|
|
||||||
### Releases
|
### Release
|
||||||
|
|
||||||
You may get releases from the [releases page](https://scm.wyattjmiller.com/wymiller/DrillSergeant/releases). This is the recommended way to start using DrillSergeant.
|
You may get releases from the [releases page](https://scm.wyattjmiller.com/wymiller/DrillSergeant/releases). This is the recommended way to start using DrillSergeant.
|
||||||
|
|
||||||
@ -42,6 +91,20 @@ There will be three separate downloads: Windows (x86 64-bit), Linux (x86 64-bit)
|
|||||||
|
|
||||||
Once downloaded and extracted, you can move it to your `$PATH`.
|
Once downloaded and extracted, you can move it to your `$PATH`.
|
||||||
|
|
||||||
|
On Windows (Powershell):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Copy-Item drillsergeant C:\Windows\
|
||||||
|
```
|
||||||
|
|
||||||
|
On Linux:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp drillsergeant /usr/local/bin
|
||||||
|
```
|
||||||
|
|
||||||
|
The following commands assume you have elevated privileges.
|
||||||
|
|
||||||
If you do not have any of these platforms, read on to source installation as that's the next best option.
|
If you do not have any of these platforms, read on to source installation as that's the next best option.
|
||||||
|
|
||||||
### Source
|
### Source
|
||||||
@ -97,3 +160,5 @@ Thank you to the developers, engineers, project managers, and contributors of th
|
|||||||
- [OpenXML](https://docs.microsoft.com/en-us/office/open-xml/open-xml-sdk)
|
- [OpenXML](https://docs.microsoft.com/en-us/office/open-xml/open-xml-sdk)
|
||||||
- [System.CommandLine](https://github.com/dotnet/command-line-api)
|
- [System.CommandLine](https://github.com/dotnet/command-line-api)
|
||||||
- [Pastel](https://github.com/silkfire/Pastel)
|
- [Pastel](https://github.com/silkfire/Pastel)
|
||||||
|
- [PdfSharpCore](https://github.com/ststeiger/PdfSharpCore)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user