Skip to content

Commit

Permalink
Merge pull request #149 from itchyny/fix-misc-20221225
Browse files Browse the repository at this point in the history
Miscellaneous fixes: coding convention fixes and some typo fixes
  • Loading branch information
Songmu authored Dec 25, 2022
2 parents 9ae224c + 183126a commit 4385160
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/actions/release/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: release
description: release maltmill
description: release ghr
inputs:
token:
description: GitHub token
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
with:
go-version: 1.x
- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: restore cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ghr
====

[![GitHub release](http://img.shields.io/github/release/tcnksm/ghr.svg?style=flat-square)][release]
[![GitHub release](https://img.shields.io/github/release/tcnksm/ghr.svg?style=flat-square)][release]
[![Test](https://github.com/tcnksm/ghr/actions/workflows/test.yml/badge.svg)][GitHub Actions]
[![PkgGoDev](https://pkg.go.dev/badge/github.com/tcnksm/ghr)][PkgGoDev]
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)][license]

[release]: https://github.com/tcnksm/ghr/releases
[GitHub Actions]: https://github.com/tcnksm/ghr/actions/workflows/test.yml
Expand Down Expand Up @@ -100,18 +100,18 @@ $ ghr \

## Install

If you are OSX user, you can use [Homebrew](http://brew.sh/):
If you are a macOS user, you can use [Homebrew](https://brew.sh/):

```bash
$ brew install ghr
```

If you are on another platform, you can download a binary from our [release page](https://github.com/tcnksm/ghr/releases) and place it in `$PATH` directory.

Or you can use `go get` (you need to use go1.7 or later),
Or you can use `go install`.

```bash
$ go get -u github.com/tcnksm/ghr
$ go install github.com/tcnksm/ghr@latest
```

## VS.
Expand All @@ -122,7 +122,7 @@ $ go get -u github.com/tcnksm/ghr

GitHub added the ability to automatically generate the body of a Release based on a format specified in
`.github/release.yml` in Oct 2021. You can read more about that format [here](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes).
ghr now has the `-generatenotes` flag to enable that content to be programmatically added instead of manually suppling the body.
ghr now has the `-generatenotes` flag to enable that content to be programmatically added instead of manually supplying the body.

## Contribution

Expand Down
4 changes: 2 additions & 2 deletions ghr.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ func (g *GHR) CreateRelease(ctx context.Context, req *github.RepositoryRelease,

// DeleteRelease removes an existing release, if it exists. If it does not exist,
// DeleteRelease returns an error
func (g *GHR) DeleteRelease(ctx context.Context, ID int64, tag string) error {
func (g *GHR) DeleteRelease(ctx context.Context, releaseID int64, tag string) error {

err := g.GitHub.DeleteRelease(ctx, ID)
err := g.GitHub.DeleteRelease(ctx, releaseID)
if err != nil {
return err
}
Expand Down
28 changes: 14 additions & 14 deletions ghr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"context"
"io/ioutil"
"io"
"testing"
"time"

Expand All @@ -13,9 +13,9 @@ func TestGHR_CreateRelease(t *testing.T) {
t.Parallel()

githubClient := testGithubClient(t)
GHR := &GHR{
ghr := &GHR{
GitHub: githubClient,
outStream: ioutil.Discard,
outStream: io.Discard,
}

testTag := "create-release"
Expand All @@ -26,21 +26,21 @@ func TestGHR_CreateRelease(t *testing.T) {
}

recreate := false
release, err := GHR.CreateRelease(context.TODO(), req, recreate)
release, err := ghr.CreateRelease(context.TODO(), req, recreate)
if err != nil {
t.Fatal("CreateRelease failed:", err)
}

defer GHR.DeleteRelease(context.TODO(), *release.ID, testTag)
defer ghr.DeleteRelease(context.TODO(), *release.ID, testTag)
}

func TestGHR_CreateReleaseWithExistingRelease(t *testing.T) {
t.Parallel()

githubClient := testGithubClient(t)
GHR := &GHR{
ghr := &GHR{
GitHub: githubClient,
outStream: ioutil.Discard,
outStream: io.Discard,
}

testTag := "create-with-existing"
Expand Down Expand Up @@ -105,14 +105,14 @@ func TestGHR_CreateReleaseWithExistingRelease(t *testing.T) {
}

// Create a release for THIS TEST
created, err := GHR.CreateRelease(context.TODO(), tc.request, tc.recreate)
created, err := ghr.CreateRelease(context.TODO(), tc.request, tc.recreate)
if err != nil {
t.Fatalf("#%d GHR.CreateRelease failed: %s", i, err)
}

// Clean up existing release
if !tc.recreate {
err = GHR.DeleteRelease(context.TODO(), *existing.ID, *existingReq.TagName)
err = ghr.DeleteRelease(context.TODO(), *existing.ID, *existingReq.TagName)
if err != nil {
t.Fatalf("#%d GHR.DeleteRelease (existing) failed: %s", i, err)
}
Expand All @@ -134,7 +134,7 @@ func TestGHR_CreateReleaseWithExistingRelease(t *testing.T) {
t.Fatalf("#%d GitHub.DeleteRelease (created) failed: %s", i, err)
}
} else {
err := GHR.DeleteRelease(context.TODO(), *created.ID, *tc.request.TagName)
err := ghr.DeleteRelease(context.TODO(), *created.ID, *tc.request.TagName)
if err != nil {
t.Fatalf("#%d GHR.DeleteRelease (created) failed: %s", i, err)
}
Expand All @@ -149,9 +149,9 @@ func TestGHR_CreateReleaseWithExistingRelease(t *testing.T) {

func TestGHR_UploadAssets(t *testing.T) {
githubClient := testGithubClient(t)
GHR := &GHR{
ghr := &GHR{
GitHub: githubClient,
outStream: ioutil.Discard,
outStream: io.Discard,
}

testTag := "ghr-upload-assets"
Expand All @@ -177,7 +177,7 @@ func TestGHR_UploadAssets(t *testing.T) {
t.Fatal("LocalAssets failed:", err)
}

if err := GHR.UploadAssets(context.TODO(), *release.ID, localTestAssets, 4); err != nil {
if err := ghr.UploadAssets(context.TODO(), *release.ID, localTestAssets, 4); err != nil {
t.Fatal("GHR.UploadAssets failed:", err)
}

Expand All @@ -192,7 +192,7 @@ func TestGHR_UploadAssets(t *testing.T) {

// Delete all assets
parallel := 4
if err := GHR.DeleteAssets(context.TODO(), *release.ID, localTestAssets, parallel); err != nil {
if err := ghr.DeleteAssets(context.TODO(), *release.ID, localTestAssets, parallel); err != nil {
t.Fatal("GHR.DeleteAssets failed:", err)
}

Expand Down
3 changes: 2 additions & 1 deletion github.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (c *GitHubClient) GetRelease(ctx context.Context, tag string) (*github.Repo
return release, nil
}

// GetDraftRelease queries the GitHub API for draft release with the specified tag
func (c *GitHubClient) GetDraftRelease(ctx context.Context, tag string) (*github.RepositoryRelease, error) {
const perPage = 100
for page := 1; page <= 2; page++ {
Expand Down Expand Up @@ -158,7 +159,7 @@ func (c *GitHubClient) GetDraftRelease(ctx context.Context, tag string) (*github
return nil, nil
}

// EditRelease edit a release object within the GitHub API
// EditRelease edits a release object within the GitHub API
func (c *GitHubClient) EditRelease(ctx context.Context, releaseID int64, req *github.RepositoryRelease) (*github.RepositoryRelease, error) {
var release *github.RepositoryRelease

Expand Down

0 comments on commit 4385160

Please sign in to comment.