Skip to content

Commit

Permalink
feat: minor refactor, docs updates, and a github workflow for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanbraun committed Oct 2, 2020
1 parent 6c81984 commit f148f9a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Tests

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out the code
uses: actions/checkout@v2

- name: Set up Go 1.14
uses: actions/setup-go@v2
with:
go-version: 1.14
id: go

- name: Run Tests
run: make test
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Commit Colors
# Commit Colors [![Test Status](https://github.com/sparkbox/commit-colors/workflows/Tests/badge.svg)](https://github.com/sparkbox/commit-colors/actions?workflow=Tests)

See a lovely color swatch in your terminal every time you author a commit. The hexadecimal color comes from the first six characters in your commit ID. Here's what it looks like:

Expand All @@ -10,17 +10,19 @@ Commit colors is written in Go, and is usable on Mac, Windows, and Linux.

## Installation

**Using Homebrew**
**Via Homebrew**

```bash
brew install sparkbox/commit-colors/commit-colors
```

**Direct Download**
**Via Direct Download**

1. Browse to [the list of releases](https://github.com/sparkbox/commit-colors/releases), and download the package that corresponds to your system (Mac, Windows or Linux).
2. Move the executable to a location on [your PATH](https://superuser.com/a/284351/193516) ([like `/usr/local/bin`](https://superuser.com/q/7150/193516), for example).

<div align="center">· · ·</div></br>

Once installed, you can do a quick test in the terminal:

```bash
Expand Down Expand Up @@ -58,7 +60,7 @@ git push origin 2.0.0
```

2. The Github Action handles the rest!
- The action publishes [a Github release](https://github.com/sparkbox/commit-colors/releases) and a [homebrew update](https://github.com/sparkbox/homebrew-commit-colors).
- Additional publishing settings can be found in `goreleaser.yml`
- The action publishes [a Github release](https://github.com/sparkbox/commit-colors/releases) and a [homebrew update](https://github.com/sparkbox/homebrew-commit-colors).
- Additional publishing settings can be found in `goreleaser.yml`


6 changes: 3 additions & 3 deletions cmd/get_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
)

// GetCommitIDFromArgs returns the first CLI argument and exits gracefully if it's missing
func GetCommitIDFromArgs() string {
func GetCommitIDFromArgs(args []string) string {
// Note: os.Args[] always contains at least one value (the path to the program).
// Any additional values that exist are the arguments passed to the program.
if len(os.Args) == 1 {
if len(args) == 1 {
fmt.Println("commit-colors expects you to provide your commit ID as an argument")
os.Exit(3)
}

return os.Args[1]
return args[1]
}

// GetHexIDFromCommitID checks an input string and truncates, if necessary, to return a valid HexID
Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
//go:generate go run gen.go

func main() {
myHexID, err := GetHexIDFromCommitID(GetCommitIDFromArgs())
myHexID, err := GetHexIDFromCommitID(GetCommitIDFromArgs(os.Args))

if err != nil {
fmt.Println(err)
Expand Down

0 comments on commit f148f9a

Please sign in to comment.