-
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
5 changed files
with
162 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package command | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"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, " ") | ||
fmt.Println(hashes[0]) | ||
fmt.Println(hashes[1]) | ||
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
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