diff --git a/README.md b/README.md index bdabd65..0955a7e 100644 --- a/README.md +++ b/README.md @@ -94,10 +94,12 @@ gitUsers: ``` ```bash -โžœ issuectl start XY-99 -Starting work on issue XY-99 ... -Workspace for XY-99 ready! ๐Ÿซก -Run `issuectl workon XY-99` to open it in VS Code +โžœ issuectl start XY-321 + ๐Ÿ—๏ธ Preparing workspace for issue XY-321... + ๐Ÿ›ฌ Cloning repositories [my-secret-project] + ๐Ÿซก Marking issue as In Progress in my-org-jira + ๐Ÿš€ Workspace for XY-321 ready! + ๐Ÿง‘โ€๐Ÿ’ป Run `issuectl workon XY-321` to open it in VS Code ``` This will: @@ -176,9 +178,11 @@ this will make your interaction with CLI more natural! Check this out: ```bash โžœ i start OPS-123 -Starting work on issue OPS-123 ... -Workspace for OPS-123 ready! ๐Ÿซก -Run `issuectl workon OPS-123` to open it in VS Code + ๐Ÿ—๏ธ Preparing workspace for issue OPS-123... + ๐Ÿ›ฌ Cloning repositories [my-secret-project] + ๐Ÿซก Marking issue as In Progress in my-org-jira + ๐Ÿš€ Workspace for OPS-123 ready! + ๐Ÿง‘โ€๐Ÿ’ป Run `issuectl workon OPS-123` to open it in VS Code ``` ```bash @@ -187,13 +191,18 @@ Run `issuectl workon OPS-123` to open it in VS Code ```bash โžœ i openpr OPS-123 -Opening PR for issue OPS-123 in github-priv -Linking PR 321 to issue OPS-123 in my-org-jira + ๐Ÿ“‚ Opening PR for issue OPS-123 in janekbaraniewski/issuectl [github-priv] + ๐Ÿ”— Linking PR 321 to issue OPS-123 in jira-priv + ``` ```bash -โžœ i finish IS-2 -Cleaning up after work on issue IS-2 +โžœ i finish OPS-123 + ๐Ÿฅ‚ Finishing work on OPS-123 + ๐Ÿ Closing issue OPS-123 in jira-priv + ๐Ÿงน Cleaning up issue workdir + ๐Ÿซฅ Removing issue config + ๐Ÿ‘ All done! ``` > This is a basic idea of workflow and what systems this can interact with at each step. diff --git a/pkg/issue.go b/pkg/issue.go index e378d53..ba8212a 100644 --- a/pkg/issue.go +++ b/pkg/issue.go @@ -31,7 +31,7 @@ func StartWorkingOnIssue(config IssuectlConfig, issueID IssueID) error { return fmt.Errorf("issueID already found in local configuration") } - Log.Infof("Starting work on issue %v ...", issueID) + Log.Infof(" ๐Ÿ—๏ธ\tPreparing workspace for issue %v...", issueID) issueBackend, issueDirPath, err := initializeIssueBackendAndDir(config, profile, issueID) if err != nil { @@ -43,11 +43,15 @@ func StartWorkingOnIssue(config IssuectlConfig, issueID IssueID) error { return err } + Log.Infof(" ๐Ÿ›ฌ\tCloning repositories %v", repositories) + newIssue, err := createAndAddRepositoriesToIssue(config, profile, issueID, issueDirPath, branchName, branchName, repositories) if err != nil { return err } + Log.Infof(" ๐Ÿซก\tMarking issue as In Progress in %v", profile.IssueBackend) + if err := issueBackend.StartIssue("", "", issueID); err != nil { return err } @@ -56,8 +60,8 @@ func StartWorkingOnIssue(config IssuectlConfig, issueID IssueID) error { return err } - Log.Infof("Workspace for %v ready! ๐Ÿซก", issueID) - Log.Infof("Run `issuectl workon %v` to open it in VS Code", issueID) + Log.Infof(" ๐Ÿš€\tWorkspace for %v ready!", issueID) + Log.Infof(" ๐Ÿง‘โ€๐Ÿ’ป\tRun `issuectl workon %v` to open it in VS Code", issueID) return nil } @@ -201,14 +205,21 @@ func OpenPullRequest(issueID IssueID) error { return err } - Log.Infof("Opening PR for issue %v in %v", issueID, profile.RepoBackend) - repo := config.GetRepository(profile.DefaultRepository) + + Log.Infof( + " ๐Ÿ“‚\tOpening PR for issue %v in %v/%v [%v]", + issueID, + repo.Owner, + repo.Name, + profile.RepoBackend, + ) + prId, err := repoBackend.OpenPullRequest( repo.Owner, repo.Name, fmt.Sprintf("%v | %v", issue.ID, issue.Name), - fmt.Sprintf("Resolves #%v", issue.ID), + fmt.Sprintf("Resolves #%v โœ…", issue.ID), "master", // TODO: make configurable issue.BranchName, ) @@ -220,7 +231,7 @@ func OpenPullRequest(issueID IssueID) error { if err != nil { return err } - Log.Infof("Linking PR %v to issue %v in %v", prId, issueID, profile.IssueBackend) + Log.Infof(" ๐Ÿ”—\tLinking PR %v to issue %v in %v", prId, issueID, profile.IssueBackend) return issueBackend.LinkIssueToRepo(repo.Owner, repo.Name, issueID, strconv.Itoa(*prId)) } @@ -231,11 +242,15 @@ func FinishWorkingOnIssue(issueID IssueID) error { profile := config.GetProfile(config.GetCurrentProfile()) repo := config.GetRepository(profile.DefaultRepository) + Log.Infof(" ๐Ÿฅ‚\tFinishing work on %v", issueID) + issueBackend, err := getIssueBackendConfigurator(config.GetBackend(profile.IssueBackend)) if err != nil { return err } + Log.Infof(" ๐Ÿ\tClosing issue %v in %v", issueID, profile.IssueBackend) + err = issueBackend.CloseIssue( repo.Owner, repo.Name, @@ -245,16 +260,24 @@ func FinishWorkingOnIssue(issueID IssueID) error { return fmt.Errorf(errFailedToCloseIssue, err) } - Log.Infof("Cleaning up after work on issue %v", issueID) - issue, found := config.GetIssue(issueID) if !found { return errors.New(errIssueIDNotFound) } + Log.Infof(" ๐Ÿงน\tCleaning up issue workdir") + if err := os.RemoveAll(issue.Dir); err != nil { return err } - return config.DeleteIssue(issueID) + Log.Infof(" ๐Ÿซฅ\tRemoving issue config") + + if err := config.DeleteIssue(issueID); err != nil { + return err + } + + Log.Infof(" ๐Ÿ‘\tAll done!") + + return nil } diff --git a/pkg/log.go b/pkg/log.go index 1e2fde6..3420ce2 100644 --- a/pkg/log.go +++ b/pkg/log.go @@ -21,6 +21,11 @@ func (l *Logger) Infof(format string, v ...interface{}) { l.output(1, fmt.Sprintf(format, v...)) } +// Infofp formats the log message, adds prefix to it and calls output function with default level 1 +func (l *Logger) Infofp(emoji string, format string, v ...interface{}) { + l.output(1, fmt.Sprintf("%v %v", emoji, fmt.Sprintf(format, v...))) +} + // V returns a verbosityLogger with the specified verbosity level func (l *Logger) V(level int) *verbosityLogger { return &verbosityLogger{parent: l, level: level}