Skip to content

Commit

Permalink
improve readme; fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
pPrecel committed Oct 20, 2023
1 parent d8c9695 commit 70d8c5c
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 188 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ tmp/
.vscode/

# development
raport
report
templates
51 changes: 38 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

---

Simple and easy-to-use tool to generate PKUP (`Podwyższone Koszty Uzyskania Przychodu` - Polish law thing) artifacts, `.patch` files, based on merged Github PullRequests.
Simple and easy-to-use tool to generate PKUP (`Podwyższone Koszty Uzyskania Przychodu` - Polish law thing) report (`.docx`) and artifacts (`.diff`).

The `pkup-gen` collects all users' PullRequests merged between the 18th (23:59:59) of the actual month and the 19th (00:00:00) of the past one. To qualify PR, the user should be an author or committer of at least one commit from the PullRequest.

Expand All @@ -44,23 +44,48 @@ Visit the [releases page](https://github.com/pPrecel/pkup-gen/releases) to downl

Example usage:

![screen1](./docs/Screenshot%202023-10-19%20at%2000.14.36.png)
![screen1](./docs/screenshot-1.png)

output:
output in the `report` dir:

```bash
ls --tree
.
├── kyma-project_keda-manager.patch
├── kyma-project_serverless-manager.patch
└── kyma-project_warden.patch
report
├── JOHN_WICK.docx
├── kyma-project_serverless-manager_0acc102b.diff
├── kyma-project_serverless-manager_29e58618.diff
├── kyma-project_serverless-manager_2c3f3c1a.diff
├── kyma-project_serverless-manager_2ee48748.diff
├── kyma-project_serverless-manager_b1919096.diff
├── kyma-project_serverless-manager_b358fab3.diff
├── kyma-project_serverless-manager_cd3621f4.diff
├── kyma-project_serverless-manager_d3306d5d.diff
├── kyma-project_serverless-manager_e6acdc66.diff
├── kyma-project_serverless-manager_ea07c894.diff
├── kyma-project_serverless-manager_fe35f71c.diff
├── kyma-project_warden_05cf15a1.diff
├── kyma-project_warden_0c730d41.diff
├── kyma-project_warden_2ef15e2d.diff
├── kyma-project_warden_5a5e192d.diff
├── kyma-project_warden_9412db87.diff
├── kyma-project_warden_96907148.diff
└── kyma-project_warden_c12e1339.diff
```

## Personal Access Token
## report

By default the `pkup-gen` generates the `report.txt` files with all info needed to fill true report.

The `.docx` report template can be specified using the `--template-path` flag. The `pkup-gen` will replace any repeat of the following key-words with the tru data:

* `pkupGenPeriodFrom` - date of the first day for the actual period
* `pkupGenPeriodTill` - date of the last day for the actual period
* `pkupGenApprovalDate` - date of the last day of the period plus one day
* `pkupGenResults` - list of all PullRequests if format <PR_TITLE>( DIFF_FILE_NAME )

## Access Token

The `pkup-gen` is using GitHub API for all HTTP operations. It does mean that to generate artifacts you have to pass a [PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) using the `--token` flag. For public projects, the generated token does not need to have any permissions.
The `pkup-gen` needs credentials to connect with the GitHub API. There are two possible ways to pass such credentials:

If the token is not specified the `pkup-gen` will try to connect your GitHub account with the [pkup-gen](https://github.com/apps/pkup-gen) app using the GitHub device API. The generated token will be saved on your local machine so next time, until the token expires, you will be logged in. Example run without the `--token` flag specified:
* By default the `pkup-gen` will reach the [pkup-gen](https://github.com/apps/pkup-gen) app using the GitHub device API. The generated token will be saved on local machine so next time, until the token expires, user will be logged in. This flow is not working with the `--enterprise-url` flag.

![screen2](./docs/Screenshot%202023-10-19%20at%2000.16.05.png)
* The `--token` flag allows to pass a [PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). For public projects, the generated token does not need to have any permissions.
10 changes: 5 additions & 5 deletions cmd/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/pPrecel/PKUP/pkg/artifacts"
"github.com/pPrecel/PKUP/pkg/github"
"github.com/pPrecel/PKUP/pkg/period"
"github.com/pPrecel/PKUP/pkg/raport"
"github.com/pPrecel/PKUP/pkg/report"
"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -88,7 +88,7 @@ func genCommandAction(ctx *cli.Context, opts *genActionOpts) error {
"before", mergedBefore.Local().Format(logTimeFormat),
))

raportResults := []raport.Result{}
reportResults := []report.Result{}
for org, repos := range opts.repos {
for i := range repos {
org := org
Expand Down Expand Up @@ -135,7 +135,7 @@ func genCommandAction(ctx *cli.Context, opts *genActionOpts) error {
}

valChan <- prs
raportResults = append(raportResults, raport.Result{
reportResults = append(reportResults, report.Result{
Org: org,
Repo: repo,
PullRequests: prs,
Expand All @@ -146,12 +146,12 @@ func genCommandAction(ctx *cli.Context, opts *genActionOpts) error {

multiView.Run()

err = raport.Render(raport.Options{
err = report.Render(report.Options{
OutputDir: opts.dir,
TemplatePath: opts.templatePath,
PeriodFrom: mergedAfter,
PeriodTill: mergedBefore,
Results: raportResults,
Results: reportResults,
})
if err != nil {
return err
Expand Down
Binary file removed docs/Screenshot 2023-10-19 at 00.14.36.png
Binary file not shown.
Binary file removed docs/Screenshot 2023-10-19 at 00.16.05.png
Binary file not shown.
Binary file added docs/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

var (
version = "local"
version = "v1.2.0"
commit = "local"
date = "local"
buildOs = "local"
Expand Down
2 changes: 1 addition & 1 deletion pkg/github/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package github

import "github.com/google/go-github/v53/github"

// TODO: generate PKUP raport for all repos in org
// TODO: generate PKUP report for all repos in org
func (gh *gh_client) listRepositories(org string) ([]*github.Repository, error) {

gh.client.Repositories.ListByOrg(gh.ctx, org, &github.RepositoryListByOrgOptions{
Expand Down
47 changes: 0 additions & 47 deletions pkg/raport/default.go

This file was deleted.

67 changes: 0 additions & 67 deletions pkg/raport/raport.go

This file was deleted.

52 changes: 0 additions & 52 deletions pkg/raport/template.go

This file was deleted.

2 changes: 1 addition & 1 deletion proposals/config-proposals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ artifacts:
ghEnterpriseURL: https://your.org.enterprise.com/
repos:
- ...
raport:
report:
template: /path/to/template.docx
gptToken: <TOKEN>
employeeName: Filip Strózik
Expand Down

0 comments on commit 70d8c5c

Please sign in to comment.