Skip to content

Commit 6e9bc84

Browse files
committed
Fix Windows path compatibility
1 parent c0581b1 commit 6e9bc84

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
VERSION := $(shell cat VERSION)
22

3-
4-
.PHONY: release # Create releases for popular systems.
3+
# Create releases for popular systems.
4+
.PHONY: release
55
release:
66
env GOARCH=amd64 GOOS=darwin go build -ldflags="-s -w" \
77
-o release/contribution-$(VERSION)-x64-macos .
@@ -10,14 +10,15 @@ release:
1010
env GOARCH=amd64 GOOS=windows go build -ldflags="-s -w" \
1111
-o release/contribution-$(VERSION)-x64.exe .
1212

13-
14-
.PHONY: release-tag # Create and push a release tag.
13+
# Create and push a release tag.
14+
.PHONY: release-tag
1515
release-tag:
1616
git tag $(VERSION)
1717
git push origin --tags
1818

1919

20-
.PHONY: README.md # Append help command to documentation.
20+
# Append help command to documentation.
21+
.PHONY: README.md
2122
README.md:
2223
@sed '/<!-- .* -->/q' README.md > README.md.tmp
2324
@mv README.md.tmp README.md # -i does not work on macOS

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Contribution is provided as a binary with a command line interface.
5555
### `contribution -help`
5656
```
5757
Draw an image on your GitHub contribution history.
58-
By Blaise Kal, 2020
58+
By Blaise Kal, 2021
5959
6060
Preview contribution history graph without pushing
6161
contribution preview -img /path/to/image.png

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1
1+
1.0.2

args.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import (
44
"flag"
55
"fmt"
66
"os"
7-
"path"
7+
"path/filepath"
8+
"time"
89
)
910

1011
// Args contains represents CLI arguments for this program.
@@ -26,7 +27,7 @@ func GetArgs() Args {
2627
}
2728

2829
push := flag.NewFlagSet("push", flag.ExitOnError)
29-
push.StringVar(&args.githubBranch, "branch", path.Base(os.Args[0]), "Git branch to push to.")
30+
push.StringVar(&args.githubBranch, "branch", "contribution", "Git branch to push to.")
3031
push.IntVar(&args.weeksAgo, "w", 0, "Weeks ago of all activity. A value of 2 will move activity two pixels to the left.")
3132
push.StringVar(&args.githubProject, "project", "", "GitHub username/project to push to. (required)")
3233
push.Usage = func() {
@@ -62,23 +63,23 @@ func GetArgs() Args {
6263
// exitWithHelp exits with global help
6364
func exitWithHelp(preview *flag.FlagSet, push *flag.FlagSet) {
6465
fmt.Fprintf(os.Stderr, "Draw an image on your GitHub contribution history.\n")
65-
fmt.Fprintf(os.Stderr, "By Blaise Kal, 2020\n\n")
66+
fmt.Fprintf(os.Stderr, "By Blaise Kal, %d\n\n", time.Now().Year())
6667
fmt.Fprintf(os.Stderr, "Preview contribution history graph without pushing\n")
67-
fmt.Fprintf(os.Stderr, " %s %s -img /path/to/image.png\n", path.Base(os.Args[0]), preview.Name())
68+
fmt.Fprintf(os.Stderr, " %s %s -img /path/to/image.png\n", filepath.Base(os.Args[0]), preview.Name())
6869
fmt.Fprintf(os.Stderr, "Preview usage and options\n")
69-
fmt.Fprintf(os.Stderr, " %s %s -help\n\n", path.Base(os.Args[0]), preview.Name())
70+
fmt.Fprintf(os.Stderr, " %s %s -help\n\n", filepath.Base(os.Args[0]), preview.Name())
7071
fmt.Fprintf(os.Stderr, "Push contribution history graph to GitHub\n")
71-
fmt.Fprintf(os.Stderr, " %s %s -img /path/to/image.png -project username/project\n", path.Base(os.Args[0]), push.Name())
72+
fmt.Fprintf(os.Stderr, " %s %s -img /path/to/image.png -project username/project\n", filepath.Base(os.Args[0]), push.Name())
7273
fmt.Fprintf(os.Stderr, "Push usage and options\n")
73-
fmt.Fprintf(os.Stderr, " %s %s -help\n", path.Base(os.Args[0]), push.Name())
74+
fmt.Fprintf(os.Stderr, " %s %s -help\n", filepath.Base(os.Args[0]), push.Name())
7475
os.Exit(0)
7576
}
7677

7778
// helpPreview exits with help on the preview subcommand
7879
func exitWithPreviewHelp(flagset *flag.FlagSet) {
7980
fmt.Fprintf(os.Stderr, "Preview contribution history graph without pushing.\n")
8081
fmt.Fprintf(os.Stderr, "Example usage:\n")
81-
fmt.Fprintf(os.Stderr, " %s %s -img image.png\n\n", path.Base(os.Args[0]), os.Args[1])
82+
fmt.Fprintf(os.Stderr, " %s %s -img image.png\n\n", filepath.Base(os.Args[0]), os.Args[1])
8283
flag.PrintDefaults()
8384
flagset.PrintDefaults()
8485
os.Exit(0)
@@ -88,7 +89,7 @@ func exitWithPreviewHelp(flagset *flag.FlagSet) {
8889
func exitWithPushHelp(flagset *flag.FlagSet) {
8990
fmt.Fprintf(os.Stderr, "Push contribution history graph to GitHub\n")
9091
fmt.Fprintf(os.Stderr, "Example usage:\n")
91-
fmt.Fprintf(os.Stderr, " %s %s -project username/project\n\n", path.Base(os.Args[0]), os.Args[1])
92+
fmt.Fprintf(os.Stderr, " %s %s -project username/project\n\n", filepath.Base(os.Args[0]), os.Args[1])
9293
flag.PrintDefaults()
9394
flagset.PrintDefaults()
9495
os.Exit(0)

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"image"
66
"io/ioutil"
77
"os"
8-
"path"
8+
"path/filepath"
99
)
1010

1111
func preview(img image.Image) error {
@@ -23,7 +23,7 @@ func push(img image.Image, args Args) error {
2323
colorMapped := getColorMappedImage(img)
2424
commits := ImageToGraphPixels(colorMapped, args)
2525

26-
dir, err := ioutil.TempDir("", path.Base(os.Args[0]))
26+
dir, err := ioutil.TempDir("", filepath.Base(os.Args[0]))
2727
if err != nil {
2828
return err
2929
}

0 commit comments

Comments
 (0)