-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
247 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Remove old artifacts | ||
|
||
on: | ||
schedule: | ||
# Every day at 1am | ||
- cron: '0 1 * * *' | ||
|
||
jobs: | ||
remove-old-artifacts: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- name: Remove old artifacts | ||
uses: c-hive/gha-remove-artifacts@v1 | ||
with: | ||
age: '1 week' | ||
# Optional inputs | ||
skip-tags: true | ||
skip-recent: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package command | ||
|
||
import ( | ||
"bufio" | ||
"github.com/DEVELOPEST/gtm-core/project" | ||
"github.com/DEVELOPEST/gtm-core/scm" | ||
"io" | ||
"log" | ||
"os" | ||
"strings" | ||
|
||
"github.com/mitchellh/cli" | ||
) | ||
|
||
// CommitCmd struct contain methods for commit command | ||
type RewriteCmd struct { | ||
UI cli.Ui | ||
} | ||
|
||
// NewCommit returns new CommitCmd struct | ||
func NewRewrite() (cli.Command, error) { | ||
return RewriteCmd{}, nil | ||
} | ||
|
||
// Help returns help for commit command | ||
func (c RewriteCmd) Help() string { | ||
helpText := ` | ||
Usage: gtm rewrite [options] | ||
Automatically called on git history rewrite. Do not use manually!. | ||
` | ||
return strings.TrimSpace(helpText) | ||
} | ||
|
||
// Run executes commit commands with args | ||
func (c RewriteCmd) Run(args []string) int { | ||
|
||
reader := bufio.NewReader(os.Stdin) | ||
for { | ||
input, err := reader.ReadString('\n') | ||
if err != nil { | ||
if err != io.EOF { | ||
log.Fatal(err) | ||
} | ||
break | ||
} | ||
input = strings.TrimSpace(input) | ||
hashes := strings.Split(input, " ") | ||
|
||
if len(hashes) < 2 { | ||
log.Fatal("Unexpected input!") | ||
} | ||
|
||
err = scm.RewriteNote(hashes[0], hashes[1], project.NoteNameSpace) | ||
|
||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
return 0 | ||
} | ||
|
||
// Synopsis return help for commit command | ||
func (c RewriteCmd) Synopsis() string { | ||
return "Update git notes on history rewrite" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package command | ||
|
||
import ( | ||
"github.com/DEVELOPEST/gtm-core/util" | ||
"github.com/mitchellh/cli" | ||
"log" | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestRewriteDefaultOptions(t *testing.T) { | ||
repo := util.NewTestRepo(t, false) | ||
defer repo.Remove() | ||
repo.Seed() | ||
err := os.Chdir(repo.Workdir()) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
(RewriteCmd{UI: new(cli.MockUi)}).Run([]string{}) | ||
|
||
ui := new(cli.MockUi) | ||
c := RewriteCmd{UI: ui} | ||
|
||
var args []string | ||
rc := c.Run(args) | ||
|
||
// TODO: Write to stdin | ||
|
||
if rc != 0 { | ||
t.Errorf("gtm rewrite(%+v), want 0 got %d, %s", args, rc, ui.ErrorWriter.String()) | ||
} | ||
} | ||
|
||
func TestRewriteInvalidOption(t *testing.T) { | ||
ui := new(cli.MockUi) | ||
c := RewriteCmd{UI: ui} | ||
|
||
args := []string{"-invalid"} | ||
rc := c.Run(args) | ||
|
||
// TODO: Write to stdin | ||
|
||
if rc != 1 { | ||
t.Errorf("gtm rewrite(%+v), want 0 got %d, %s", args, rc, ui.ErrorWriter) | ||
} | ||
if !strings.Contains(ui.OutputWriter.String(), "Usage:") { | ||
t.Errorf("gtm rewrite(%+v), want 'Usage:' got %d, %s", args, rc, ui.OutputWriter.String()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.