Skip to content

Commit

Permalink
fix: support all grc codecommit variants (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
ga-paul-t authored Mar 6, 2022
1 parent e8dcf56 commit 5872e00
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Gemba Advantage
# Copyright (c) 2022 Gemba Advantage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Gemba Advantage
# Copyright (c) 2022 Gemba Advantage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Gemba Advantage
# Copyright (c) 2022 Gemba Advantage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -36,19 +36,32 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
- name: Cache Go
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Task
uses: arduino/setup-task@v1
- name: Lint
uses: golangci/[email protected]
with:
skip-go-installation: true
- name: Test
run: make test
run: task test
- name: Code Coverage
uses: codecov/[email protected]
- name: Build
run: make build
run: task build
- name: Tag
if: github.ref == 'refs/heads/main'
uses: gembaadvantage/uplift-action@v1
uses: gembaadvantage/[email protected]
with:
args: tag
env:
GITHUB_TOKEN: ${{ secrets.GH_UPLIFT }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Gemba Advantage
# Copyright (c) 2022 Gemba Advantage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17
- name: Import GPG key
id: import_gpg
uses: hashicorp/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Gemba Advantage
# Copyright (c) 2022 Gemba Advantage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 13 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Gemba Advantage
# Copyright (c) 2022 Gemba Advantage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -61,10 +61,13 @@ archives:
files:
- README.md
- LICENSE

checksum:
name_template: "{{ .ProjectName }}_{{ .Tag }}_checksums.txt"

signs:
- artifacts: checksum

brews:
- name: git-remote-codecommit
tap:
Expand All @@ -79,10 +82,19 @@ brews:
test: |
installed_version = shell_output("#{bin}/git-remote-codecommit version --short 2>&1")
assert_match "v#{version}", installed_version
scoop:
bucket:
owner: gembaadvantage
name: scoops
homepage: "https://github.com/gembaadvantage/git-remote-codecommit"
description: "A git remote helper that removes the need for dedicated CodeCommit user credentials"
license: MIT

rigs:
- rig:
owner: gembaadvantage
name: fish-food
homepage: "https://github.com/gembaadvantage/git-remote-codecommit"
description: "A git remote helper that removes the need for dedicated CodeCommit user credentials"
license: MIT
2 changes: 1 addition & 1 deletion .uplift.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021 Gemba Advantage
# Copyright (c) 2022 Gemba Advantage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Gemba Advantage
Copyright (c) 2022 Gemba Advantage

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
67 changes: 0 additions & 67 deletions Makefile

This file was deleted.

9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ curl https://raw.githubusercontent.com/gembaadvantage/git-remote-codecommit/main

Clone the repository using your standard git syntax, but provide the clone URL using the `codecommit` protocol format of:

```text
codecommit::<REGION>://<PROFILE>@<REPOSITORY>
```
- `codecommit://repository`
- `codecommit://profile@repository`
- `codecommit::region://repository`
- `codecommit::region://profile@repository`

```sh
$ git clone codecommit::eu-west-1://repository
Expand All @@ -52,7 +53,7 @@ Both `git pull` and `git push` operations will behave as normal.

### AWS Named Profile

Depending on your chosen authentication mechansim, you may need to provide an AWS named profile to authenticate with CodeCommit. To do this, provide the named profile, suffixed with an `@`, before the repository name.
Depending on your chosen authentication mechanism, you may need to provide an AWS named profile to authenticate with CodeCommit. To do this, prefix your repository name with `profile@`.

```sh
git clone codecommit::eu-west-1://profile@repository
Expand Down
65 changes: 65 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright (c) 2022 Gemba Advantage
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# in the Software without restriction, including without limitation the rights
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

version: "3"

vars:
BINDIR: bin
BINNAME: git-remote-codecommit
GIT_COMMIT:
sh: git rev-parse HEAD
GIT_SHA:
sh: git rev-parse --short HEAD
GIT_BRANCH:
sh: git branch --show-current
LDFLAGS: >
-X github.com/gembaadvantage/git-remote-codecommit/internal/version.version=dev-{{.GIT_SHA}}
-X github.com/gembaadvantage/git-remote-codecommit/internal/version.gitCommit={{.GIT_COMMIT}}
-X github.com/gembaadvantage/git-remote-codecommit/internal/version.gitBranch={{.GIT_BRANCH}}
-X github.com/gembaadvantage/git-remote-codecommit/internal/version.buildDate={{now | date "2006-01-02T15:04:05Z07:00"}}
tasks:
default:
desc: Runs all of the default tasks
cmds:
- task: clean
- task: lint
- task: test
- task: build

build:
desc: Build the git-remote-codecommit binary
cmds:
- go build -ldflags '-s -w {{.LDFLAGS}}' -o '{{.BINDIR}}/{{.BINNAME}}' ./cmd/grc

test:
desc: Run the tests
cmds:
- go test -race -vet=off -p 1 -covermode=atomic -coverprofile=coverage.out ./...

lint:
desc: Lint the code using golangci
cmds:
- golangci-lint run --timeout 5m0s

clean:
desc: Remove any built artifacts
cmds:
- rm -rf {{.BINDIR}}
2 changes: 1 addition & 1 deletion cmd/grc/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2021 Gemba Advantage
Copyright (c) 2022 Gemba Advantage
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions cmd/grc/root.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2021 Gemba Advantage
Copyright (c) 2022 Gemba Advantage
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -56,7 +56,7 @@ func newRootCmd(out io.Writer, args []string) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
opts.Cmd = args[0]

// Prefix protocol, as it will have been stipped off by the git client
// Prefix protocol, as it will have been stripped off by the git client
opts.RemoteURL = "codecommit::" + args[1]

return opts.Run(out)
Expand Down Expand Up @@ -85,7 +85,7 @@ func (o gitOptions) Run(out io.Writer) error {
}

// Translate and then sign the RemoteURL
grcURL, err := translate.FromGrc(o.RemoteURL)
grcURL, err := translate.FromGRC(o.RemoteURL)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/grc/root_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2021 Gemba Advantage
Copyright (c) 2022 Gemba Advantage
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion cmd/grc/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2021 Gemba Advantage
Copyright (c) 2022 Gemba Advantage
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/aws/aws-sdk-go-v2/config v1.14.0
github.com/gembaadvantage/codecommit-sign v1.1.0
github.com/gembaadvantage/codecommit-sign v1.3.1
github.com/spf13/cobra v1.3.0
)

Expand Down
Loading

0 comments on commit 5872e00

Please sign in to comment.