Skip to content

Commit 78d0979

Browse files
Update log messages
1 parent 66d92b7 commit 78d0979

File tree

3 files changed

+58
-21
lines changed

3 files changed

+58
-21
lines changed

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ gitUsers:
9494
```
9595

9696
```bash
97-
➜ issuectl start XY-99
98-
Starting work on issue XY-99 ...
99-
Workspace for XY-99 ready! 🫡
100-
Run `issuectl workon XY-99` to open it in VS Code
97+
➜ issuectl start XY-321
98+
🏗️ Preparing workspace for issue XY-321...
99+
🛬 Cloning repositories [my-secret-project]
100+
🫡 Marking issue as In Progress in my-org-jira
101+
🚀 Workspace for XY-321 ready!
102+
🧑‍💻 Run `issuectl workon XY-321` to open it in VS Code
101103
```
102104

103105
This will:
@@ -176,9 +178,11 @@ this will make your interaction with CLI more natural! Check this out:
176178

177179
```bash
178180
➜ i start OPS-123
179-
Starting work on issue OPS-123 ...
180-
Workspace for OPS-123 ready! 🫡
181-
Run `issuectl workon OPS-123` to open it in VS Code
181+
🏗️ Preparing workspace for issue OPS-123...
182+
🛬 Cloning repositories [my-secret-project]
183+
🫡 Marking issue as In Progress in my-org-jira
184+
🚀 Workspace for OPS-123 ready!
185+
🧑‍💻 Run `issuectl workon OPS-123` to open it in VS Code
182186
```
183187

184188
```bash
@@ -187,13 +191,18 @@ Run `issuectl workon OPS-123` to open it in VS Code
187191

188192
```bash
189193
➜ i openpr OPS-123
190-
Opening PR for issue OPS-123 in github-priv
191-
Linking PR 321 to issue OPS-123 in my-org-jira
194+
📂 Opening PR for issue OPS-123 in janekbaraniewski/issuectl [github-priv]
195+
🔗 Linking PR 321 to issue OPS-123 in jira-priv
196+
192197
```
193198
194199
```bash
195-
➜ i finish IS-2
196-
Cleaning up after work on issue IS-2
200+
➜ i finish OPS-123
201+
🥂 Finishing work on OPS-123
202+
🏁 Closing issue OPS-123 in jira-priv
203+
🧹 Cleaning up issue workdir
204+
🫥 Removing issue config
205+
👍 All done!
197206
```
198207
199208
> This is a basic idea of workflow and what systems this can interact with at each step.

pkg/issue.go

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func StartWorkingOnIssue(config IssuectlConfig, issueID IssueID) error {
3131
return fmt.Errorf("issueID already found in local configuration")
3232
}
3333

34-
Log.Infof("Starting work on issue %v ...", issueID)
34+
Log.Infof(" 🏗️\tPreparing workspace for issue %v...", issueID)
3535

3636
issueBackend, issueDirPath, err := initializeIssueBackendAndDir(config, profile, issueID)
3737
if err != nil {
@@ -43,11 +43,15 @@ func StartWorkingOnIssue(config IssuectlConfig, issueID IssueID) error {
4343
return err
4444
}
4545

46+
Log.Infof(" 🛬\tCloning repositories %v", repositories)
47+
4648
newIssue, err := createAndAddRepositoriesToIssue(config, profile, issueID, issueDirPath, branchName, branchName, repositories)
4749
if err != nil {
4850
return err
4951
}
5052

53+
Log.Infof(" 🫡\tMarking issue as In Progress in %v", profile.IssueBackend)
54+
5155
if err := issueBackend.StartIssue("", "", issueID); err != nil {
5256
return err
5357
}
@@ -56,8 +60,8 @@ func StartWorkingOnIssue(config IssuectlConfig, issueID IssueID) error {
5660
return err
5761
}
5862

59-
Log.Infof("Workspace for %v ready! 🫡", issueID)
60-
Log.Infof("Run `issuectl workon %v` to open it in VS Code", issueID)
63+
Log.Infof(" 🚀\tWorkspace for %v ready!", issueID)
64+
Log.Infof(" 🧑‍💻\tRun `issuectl workon %v` to open it in VS Code", issueID)
6165
return nil
6266
}
6367

@@ -201,14 +205,21 @@ func OpenPullRequest(issueID IssueID) error {
201205
return err
202206
}
203207

204-
Log.Infof("Opening PR for issue %v in %v", issueID, profile.RepoBackend)
205-
206208
repo := config.GetRepository(profile.DefaultRepository)
209+
210+
Log.Infof(
211+
" 📂\tOpening PR for issue %v in %v/%v [%v]",
212+
issueID,
213+
repo.Owner,
214+
repo.Name,
215+
profile.RepoBackend,
216+
)
217+
207218
prId, err := repoBackend.OpenPullRequest(
208219
repo.Owner,
209220
repo.Name,
210221
fmt.Sprintf("%v | %v", issue.ID, issue.Name),
211-
fmt.Sprintf("Resolves #%v", issue.ID),
222+
fmt.Sprintf("Resolves #%v", issue.ID),
212223
"master", // TODO: make configurable
213224
issue.BranchName,
214225
)
@@ -220,7 +231,7 @@ func OpenPullRequest(issueID IssueID) error {
220231
if err != nil {
221232
return err
222233
}
223-
Log.Infof("Linking PR %v to issue %v in %v", prId, issueID, profile.IssueBackend)
234+
Log.Infof(" 🔗\tLinking PR %v to issue %v in %v", prId, issueID, profile.IssueBackend)
224235

225236
return issueBackend.LinkIssueToRepo(repo.Owner, repo.Name, issueID, strconv.Itoa(*prId))
226237
}
@@ -231,11 +242,15 @@ func FinishWorkingOnIssue(issueID IssueID) error {
231242
profile := config.GetProfile(config.GetCurrentProfile())
232243
repo := config.GetRepository(profile.DefaultRepository)
233244

245+
Log.Infof(" 🥂\tFinishing work on %v", issueID)
246+
234247
issueBackend, err := getIssueBackendConfigurator(config.GetBackend(profile.IssueBackend))
235248
if err != nil {
236249
return err
237250
}
238251

252+
Log.Infof(" 🏁\tClosing issue %v in %v", issueID, profile.IssueBackend)
253+
239254
err = issueBackend.CloseIssue(
240255
repo.Owner,
241256
repo.Name,
@@ -245,16 +260,24 @@ func FinishWorkingOnIssue(issueID IssueID) error {
245260
return fmt.Errorf(errFailedToCloseIssue, err)
246261
}
247262

248-
Log.Infof("Cleaning up after work on issue %v", issueID)
249-
250263
issue, found := config.GetIssue(issueID)
251264
if !found {
252265
return errors.New(errIssueIDNotFound)
253266
}
254267

268+
Log.Infof(" 🧹\tCleaning up issue workdir")
269+
255270
if err := os.RemoveAll(issue.Dir); err != nil {
256271
return err
257272
}
258273

259-
return config.DeleteIssue(issueID)
274+
Log.Infof(" 🫥\tRemoving issue config")
275+
276+
if err := config.DeleteIssue(issueID); err != nil {
277+
return err
278+
}
279+
280+
Log.Infof(" 👍\tAll done!")
281+
282+
return nil
260283
}

pkg/log.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ func (l *Logger) Infof(format string, v ...interface{}) {
2121
l.output(1, fmt.Sprintf(format, v...))
2222
}
2323

24+
// Infofp formats the log message, adds prefix to it and calls output function with default level 1
25+
func (l *Logger) Infofp(emoji string, format string, v ...interface{}) {
26+
l.output(1, fmt.Sprintf("%v %v", emoji, fmt.Sprintf(format, v...)))
27+
}
28+
2429
// V returns a verbosityLogger with the specified verbosity level
2530
func (l *Logger) V(level int) *verbosityLogger {
2631
return &verbosityLogger{parent: l, level: level}

0 commit comments

Comments
 (0)