Skip to content

Commit

Permalink
Update log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
janekbaraniewski committed Jul 24, 2023
1 parent 66d92b7 commit 78d0979
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 21 deletions.
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
43 changes: 33 additions & 10 deletions pkg/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand All @@ -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
}

Expand Down Expand Up @@ -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,
)
Expand All @@ -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))
}
Expand All @@ -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,
Expand All @@ -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
}
5 changes: 5 additions & 0 deletions pkg/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 78d0979

Please sign in to comment.