• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

umputun / ralphex / 21841600020

09 Feb 2026 09:34PM UTC coverage: 80.502% (-0.3%) from 80.776%
21841600020

Pull #79

github

umputun
fix(git): address copilot review feedback on external backend

add -- separator before paths in Add, MoveFile, IsIgnored to prevent
filenames starting with - from being interpreted as flags. improve
run() error to wrap underlying error when git output is empty.
use checkout -B in tests for idempotent branch creation.
Pull Request #79: Add external git backend option

282 of 371 new or added lines in 5 files covered. (76.01%)

13 existing lines in 1 file now uncovered.

5165 of 6416 relevant lines covered (80.5%)

202.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.39
/pkg/progress/progress.go
1
// Package progress provides timestamped logging to file and stdout with color support.
2
package progress
3

4
import (
5
        "fmt"
6
        "io"
7
        "os"
8
        "path/filepath"
9
        "strconv"
10
        "strings"
11
        "time"
12

13
        "github.com/dustin/go-humanize"
14
        "github.com/fatih/color"
15
        "golang.org/x/term"
16

17
        "github.com/umputun/ralphex/pkg/config"
18
        "github.com/umputun/ralphex/pkg/status"
19
)
20

21
// Colors holds all color configuration for output formatting.
22
// use NewColors to create from config.ColorConfig.
23
type Colors struct {
24
        task       *color.Color
25
        review     *color.Color
26
        codex      *color.Color
27
        claudeEval *color.Color
28
        warn       *color.Color
29
        err        *color.Color
30
        signal     *color.Color
31
        timestamp  *color.Color
32
        info       *color.Color
33
        phases     map[status.Phase]*color.Color
34
}
35

36
// NewColors creates Colors from config.ColorConfig.
37
// all colors must be provided - use config with embedded defaults fallback.
38
// panics if any color value is invalid (configuration error).
39
func NewColors(cfg config.ColorConfig) *Colors {
22✔
40
        c := &Colors{phases: make(map[status.Phase]*color.Color)}
22✔
41
        c.task = parseColorOrPanic(cfg.Task, "task")
22✔
42
        c.review = parseColorOrPanic(cfg.Review, "review")
22✔
43
        c.codex = parseColorOrPanic(cfg.Codex, "codex")
22✔
44
        c.claudeEval = parseColorOrPanic(cfg.ClaudeEval, "claude_eval")
22✔
45
        c.warn = parseColorOrPanic(cfg.Warn, "warn")
22✔
46
        c.err = parseColorOrPanic(cfg.Error, "error")
22✔
47
        c.signal = parseColorOrPanic(cfg.Signal, "signal")
22✔
48
        c.timestamp = parseColorOrPanic(cfg.Timestamp, "timestamp")
22✔
49
        c.info = parseColorOrPanic(cfg.Info, "info")
22✔
50

22✔
51
        c.phases[status.PhaseTask] = c.task
22✔
52
        c.phases[status.PhaseReview] = c.review
22✔
53
        c.phases[status.PhaseCodex] = c.codex
22✔
54
        c.phases[status.PhaseClaudeEval] = c.claudeEval
22✔
55
        c.phases[status.PhasePlan] = c.task     // plan phase uses task color (green)
22✔
56
        c.phases[status.PhaseFinalize] = c.task // finalize phase uses task color (green)
22✔
57

22✔
58
        return c
22✔
59
}
22✔
60

61
// parseColorOrPanic parses RGB string and returns color, panics on invalid input.
62
func parseColorOrPanic(s, name string) *color.Color {
200✔
63
        parseRGB := func(s string) []int {
400✔
64
                if s == "" {
202✔
65
                        return nil
2✔
66
                }
2✔
67
                parts := strings.Split(s, ",")
198✔
68
                if len(parts) != 3 {
203✔
69
                        return nil
5✔
70
                }
5✔
71

72
                // parse each component
73
                r, err := strconv.Atoi(strings.TrimSpace(parts[0]))
193✔
74
                if err != nil || r < 0 || r > 255 {
196✔
75
                        return nil
3✔
76
                }
3✔
77
                g, err := strconv.Atoi(strings.TrimSpace(parts[1]))
190✔
78
                if err != nil || g < 0 || g > 255 {
193✔
79
                        return nil
3✔
80
                }
3✔
81
                b, err := strconv.Atoi(strings.TrimSpace(parts[2]))
187✔
82
                if err != nil || b < 0 || b > 255 {
190✔
83
                        return nil
3✔
84
                }
3✔
85
                return []int{r, g, b}
184✔
86
        }
87

88
        rgb := parseRGB(s)
200✔
89
        if rgb == nil {
216✔
90
                panic(fmt.Sprintf("invalid color_%s value: %q", name, s))
16✔
91
        }
92
        return color.RGB(rgb[0], rgb[1], rgb[2])
184✔
93
}
94

95
// Info returns the info color for informational messages.
96
func (c *Colors) Info() *color.Color { return c.info }
8✔
97

98
// ForPhase returns the color for the given execution phase.
99
func (c *Colors) ForPhase(p status.Phase) *color.Color {
15✔
100
        if clr, ok := c.phases[p]; ok {
27✔
101
                return clr
12✔
102
        }
12✔
103
        return c.task // fallback to task color for unknown/empty phase
3✔
104
}
105

106
// Timestamp returns the timestamp color.
107
func (c *Colors) Timestamp() *color.Color { return c.timestamp }
17✔
108

109
// Warn returns the warning color.
110
func (c *Colors) Warn() *color.Color { return c.warn }
4✔
111

112
// Error returns the error color.
113
func (c *Colors) Error() *color.Color { return c.err }
3✔
114

115
// Signal returns the signal color.
116
func (c *Colors) Signal() *color.Color { return c.signal }
2✔
117

118
// Logger writes timestamped output to both file and stdout.
119
type Logger struct {
120
        file      *os.File
121
        stdout    io.Writer
122
        startTime time.Time
123
        holder    *status.PhaseHolder
124
        colors    *Colors
125
}
126

127
// Config holds logger configuration.
128
type Config struct {
129
        PlanFile        string // plan filename (used to derive progress filename)
130
        PlanDescription string // plan description for plan mode (used for filename)
131
        Mode            string // execution mode: full, review, codex-only, plan
132
        Branch          string // current git branch
133
        NoColor         bool   // disable color output (sets color.NoColor globally)
134
}
135

136
// NewLogger creates a logger writing to both a progress file and stdout.
137
// colors must be provided (created via NewColors from config).
138
// holder is the shared PhaseHolder for reading the current execution phase.
139
func NewLogger(cfg Config, colors *Colors, holder *status.PhaseHolder) (*Logger, error) {
23✔
140
        // set global color setting
23✔
141
        if cfg.NoColor {
35✔
142
                color.NoColor = true
12✔
143
        }
12✔
144

145
        progressPath := progressFilename(cfg.PlanFile, cfg.PlanDescription, cfg.Mode)
23✔
146

23✔
147
        // ensure progress files are tracked by creating parent dir
23✔
148
        if dir := filepath.Dir(progressPath); dir != "." {
23✔
149
                if err := os.MkdirAll(dir, 0o750); err != nil {
×
150
                        return nil, fmt.Errorf("create progress dir: %w", err)
×
UNCOV
151
                }
×
152
        }
153

154
        f, err := os.Create(progressPath) //nolint:gosec // path derived from plan filename
23✔
155
        if err != nil {
23✔
156
                return nil, fmt.Errorf("create progress file: %w", err)
×
UNCOV
157
        }
×
158

159
        // acquire exclusive lock on progress file to signal active session
160
        // the lock is held for the duration of execution and released on Close()
161
        if err := lockFile(f); err != nil {
23✔
162
                f.Close()
×
163
                return nil, fmt.Errorf("acquire file lock: %w", err)
×
UNCOV
164
        }
×
165
        registerActiveLock(f.Name())
23✔
166

23✔
167
        l := &Logger{
23✔
168
                file:      f,
23✔
169
                stdout:    os.Stdout,
23✔
170
                startTime: time.Now(),
23✔
171
                holder:    holder,
23✔
172
                colors:    colors,
23✔
173
        }
23✔
174

23✔
175
        // write header
23✔
176
        planStr := cfg.PlanFile
23✔
177
        if planStr == "" {
43✔
178
                planStr = "(no plan - review only)"
20✔
179
        }
20✔
180
        l.writeFile("# Ralphex Progress Log\n")
23✔
181
        l.writeFile("Plan: %s\n", planStr)
23✔
182
        l.writeFile("Branch: %s\n", cfg.Branch)
23✔
183
        l.writeFile("Mode: %s\n", cfg.Mode)
23✔
184
        l.writeFile("Started: %s\n", time.Now().Format("2006-01-02 15:04:05"))
23✔
185
        l.writeFile("%s\n\n", strings.Repeat("-", 60))
23✔
186

23✔
187
        return l, nil
23✔
188
}
189

190
// Path returns the progress file path.
191
func (l *Logger) Path() string {
27✔
192
        if l.file == nil {
27✔
193
                return ""
×
UNCOV
194
        }
×
195
        return l.file.Name()
27✔
196
}
197

198
// timestampFormat is the format for timestamps: YY-MM-DD HH:MM:SS
199
const timestampFormat = "06-01-02 15:04:05"
200

201
// Print writes a timestamped message to both file and stdout.
202
func (l *Logger) Print(format string, args ...any) {
6✔
203
        msg := fmt.Sprintf(format, args...)
6✔
204
        timestamp := time.Now().Format(timestampFormat)
6✔
205

6✔
206
        // write to file without color
6✔
207
        l.writeFile("[%s] %s\n", timestamp, msg)
6✔
208

6✔
209
        // write to stdout with color
6✔
210
        phaseColor := l.colors.ForPhase(l.holder.Get())
6✔
211
        tsStr := l.colors.Timestamp().Sprintf("[%s]", timestamp)
6✔
212
        msgStr := phaseColor.Sprint(msg)
6✔
213
        l.writeStdout("%s %s\n", tsStr, msgStr)
6✔
214
}
6✔
215

216
// PrintRaw writes without timestamp (for streaming output).
217
func (l *Logger) PrintRaw(format string, args ...any) {
1✔
218
        msg := fmt.Sprintf(format, args...)
1✔
219
        l.writeFile("%s", msg)
1✔
220
        l.writeStdout("%s", msg)
1✔
221
}
1✔
222

223
// PrintSection writes a section header without timestamp in yellow.
224
// format: "\n--- {label} ---\n"
225
func (l *Logger) PrintSection(section status.Section) {
1✔
226
        header := fmt.Sprintf("\n--- %s ---\n", section.Label)
1✔
227
        l.writeFile("%s", header)
1✔
228
        l.writeStdout("%s", l.colors.Warn().Sprint(header))
1✔
229
}
1✔
230

231
// getTerminalWidth returns terminal width, using COLUMNS env var or syscall.
232
// Defaults to 80 if detection fails. Returns content width (total - 20 for timestamp).
233
func getTerminalWidth() int {
4✔
234
        const minWidth = 40
4✔
235

4✔
236
        // try COLUMNS env var first
4✔
237
        if cols := os.Getenv("COLUMNS"); cols != "" {
7✔
238
                if w, err := strconv.Atoi(cols); err == nil && w > 0 {
5✔
239
                        contentWidth := w - 20 // leave room for timestamp prefix
2✔
240
                        if contentWidth < minWidth {
3✔
241
                                return minWidth
1✔
242
                        }
1✔
243
                        return contentWidth
1✔
244
                }
245
        }
246

247
        // try terminal syscall
248
        if w, _, err := term.GetSize(int(os.Stdout.Fd())); err == nil && w > 0 {
2✔
249
                contentWidth := w - 20
×
250
                if contentWidth < minWidth {
×
251
                        return minWidth
×
252
                }
×
UNCOV
253
                return contentWidth
×
254
        }
255

256
        return 80 - 20 // default 80 columns minus timestamp
2✔
257
}
258

259
// wrapText wraps text to specified width, breaking on word boundaries.
260
func wrapText(text string, width int) string {
6✔
261
        if width <= 0 || len(text) <= width {
10✔
262
                return text
4✔
263
        }
4✔
264

265
        var result strings.Builder
2✔
266
        words := strings.Fields(text)
2✔
267
        lineLen := 0
2✔
268

2✔
269
        for i, word := range words {
11✔
270
                wordLen := len(word)
9✔
271

9✔
272
                if i == 0 {
11✔
273
                        result.WriteString(word)
2✔
274
                        lineLen = wordLen
2✔
275
                        continue
2✔
276
                }
277

278
                // check if word fits on current line
279
                if lineLen+1+wordLen <= width {
12✔
280
                        result.WriteString(" ")
5✔
281
                        result.WriteString(word)
5✔
282
                        lineLen += 1 + wordLen
5✔
283
                } else {
7✔
284
                        // start new line
2✔
285
                        result.WriteString("\n")
2✔
286
                        result.WriteString(word)
2✔
287
                        lineLen = wordLen
2✔
288
                }
2✔
289
        }
290

291
        return result.String()
2✔
292
}
293

294
// PrintAligned writes text with timestamp on each line, suppressing empty lines.
295
func (l *Logger) PrintAligned(text string) {
2✔
296
        if text == "" {
3✔
297
                return
1✔
298
        }
1✔
299

300
        // trim trailing newlines to avoid extra blank lines
301
        text = strings.TrimRight(text, "\n")
1✔
302
        if text == "" {
1✔
303
                return
×
UNCOV
304
        }
×
305

306
        phaseColor := l.colors.ForPhase(l.holder.Get())
1✔
307

1✔
308
        // wrap text to terminal width
1✔
309
        width := getTerminalWidth()
1✔
310

1✔
311
        // split into lines, wrap each long line, then process
1✔
312
        var lines []string
1✔
313
        for line := range strings.SplitSeq(text, "\n") {
4✔
314
                if len(line) > width {
3✔
315
                        wrapped := wrapText(line, width)
×
316
                        for wrappedLine := range strings.SplitSeq(wrapped, "\n") {
×
317
                                lines = append(lines, wrappedLine)
×
UNCOV
318
                        }
×
319
                } else {
3✔
320
                        lines = append(lines, line)
3✔
321
                }
3✔
322
        }
323

324
        for _, line := range lines {
4✔
325
                if line == "" {
3✔
UNCOV
326
                        continue // skip empty lines
×
327
                }
328

329
                // add indent for list items
330
                displayLine := formatListItem(line)
3✔
331

3✔
332
                // timestamp each line
3✔
333
                timestamp := time.Now().Format(timestampFormat)
3✔
334
                tsPrefix := l.colors.Timestamp().Sprintf("[%s]", timestamp)
3✔
335
                l.writeFile("[%s] %s\n", timestamp, displayLine)
3✔
336

3✔
337
                // use red for signal lines
3✔
338
                lineColor := phaseColor
3✔
339

3✔
340
                // format signal lines nicely
3✔
341
                if sig := extractSignal(line); sig != "" {
3✔
342
                        displayLine = sig
×
343
                        lineColor = l.colors.Signal()
×
UNCOV
344
                }
×
345

346
                l.writeStdout("%s %s\n", tsPrefix, lineColor.Sprint(displayLine))
3✔
347
        }
348
}
349

350
// extractSignal extracts signal name from <<<RALPHEX:SIGNAL_NAME>>> format.
351
// returns empty string if no signal found.
352
func extractSignal(line string) string {
12✔
353
        const prefix = "<<<RALPHEX:"
12✔
354
        const suffix = ">>>"
12✔
355

12✔
356
        start := strings.Index(line, prefix)
12✔
357
        if start == -1 {
18✔
358
                return ""
6✔
359
        }
6✔
360

361
        end := strings.Index(line[start:], suffix)
6✔
362
        if end == -1 {
7✔
363
                return ""
1✔
364
        }
1✔
365

366
        return line[start+len(prefix) : start+end]
5✔
367
}
368

369
// formatListItem adds 2-space indent for list items (numbered or bulleted).
370
// detects patterns like "1. ", "12. ", "- ", "* " at line start.
371
func formatListItem(line string) string {
9✔
372
        trimmed := strings.TrimLeft(line, " \t")
9✔
373
        if trimmed == line { // no leading whitespace
17✔
374
                if isListItem(trimmed) {
12✔
375
                        return "  " + line
4✔
376
                }
4✔
377
        }
378
        return line
5✔
379
}
380

381
// isListItem returns true if line starts with a list marker.
382
func isListItem(line string) bool {
19✔
383
        // check for "- " or "* " (bullet lists)
19✔
384
        if strings.HasPrefix(line, "- ") || strings.HasPrefix(line, "* ") {
23✔
385
                return true
4✔
386
        }
4✔
387
        // check for numbered lists like "1. ", "12. ", "123. "
388
        for i, r := range line {
40✔
389
                if r >= '0' && r <= '9' {
36✔
390
                        continue
11✔
391
                }
392
                if r == '.' && i > 0 && i < len(line)-1 && line[i+1] == ' ' {
19✔
393
                        return true
5✔
394
                }
5✔
395
                break
9✔
396
        }
397
        return false
10✔
398
}
399

400
// Error writes an error message in red.
401
func (l *Logger) Error(format string, args ...any) {
1✔
402
        msg := fmt.Sprintf(format, args...)
1✔
403
        timestamp := time.Now().Format(timestampFormat)
1✔
404

1✔
405
        l.writeFile("[%s] ERROR: %s\n", timestamp, msg)
1✔
406

1✔
407
        tsStr := l.colors.Timestamp().Sprintf("[%s]", timestamp)
1✔
408
        errStr := l.colors.Error().Sprintf("ERROR: %s", msg)
1✔
409
        l.writeStdout("%s %s\n", tsStr, errStr)
1✔
410
}
1✔
411

412
// Warn writes a warning message in yellow.
413
func (l *Logger) Warn(format string, args ...any) {
1✔
414
        msg := fmt.Sprintf(format, args...)
1✔
415
        timestamp := time.Now().Format(timestampFormat)
1✔
416

1✔
417
        l.writeFile("[%s] WARN: %s\n", timestamp, msg)
1✔
418

1✔
419
        tsStr := l.colors.Timestamp().Sprintf("[%s]", timestamp)
1✔
420
        warnStr := l.colors.Warn().Sprintf("WARN: %s", msg)
1✔
421
        l.writeStdout("%s %s\n", tsStr, warnStr)
1✔
422
}
1✔
423

424
// LogQuestion logs a question and its options for plan creation mode.
425
// format: QUESTION: <question>\n OPTIONS: <opt1>, <opt2>, ...
426
func (l *Logger) LogQuestion(question string, options []string) {
1✔
427
        timestamp := time.Now().Format(timestampFormat)
1✔
428

1✔
429
        l.writeFile("[%s] QUESTION: %s\n", timestamp, question)
1✔
430
        l.writeFile("[%s] OPTIONS: %s\n", timestamp, strings.Join(options, ", "))
1✔
431

1✔
432
        tsStr := l.colors.Timestamp().Sprintf("[%s]", timestamp)
1✔
433
        questionStr := l.colors.Info().Sprintf("QUESTION: %s", question)
1✔
434
        optionsStr := l.colors.Info().Sprintf("OPTIONS: %s", strings.Join(options, ", "))
1✔
435
        l.writeStdout("%s %s\n", tsStr, questionStr)
1✔
436
        l.writeStdout("%s %s\n", tsStr, optionsStr)
1✔
437
}
1✔
438

439
// LogAnswer logs the user's answer for plan creation mode.
440
// format: ANSWER: <answer>
441
func (l *Logger) LogAnswer(answer string) {
1✔
442
        timestamp := time.Now().Format(timestampFormat)
1✔
443

1✔
444
        l.writeFile("[%s] ANSWER: %s\n", timestamp, answer)
1✔
445

1✔
446
        tsStr := l.colors.Timestamp().Sprintf("[%s]", timestamp)
1✔
447
        answerStr := l.colors.Info().Sprintf("ANSWER: %s", answer)
1✔
448
        l.writeStdout("%s %s\n", tsStr, answerStr)
1✔
449
}
1✔
450

451
// LogDraftReview logs the user's draft review action and optional feedback.
452
// format: DRAFT REVIEW: <action>
453
// if feedback is non-empty: FEEDBACK: <feedback>
454
func (l *Logger) LogDraftReview(action, feedback string) {
2✔
455
        timestamp := time.Now().Format(timestampFormat)
2✔
456

2✔
457
        l.writeFile("[%s] DRAFT REVIEW: %s\n", timestamp, action)
2✔
458

2✔
459
        tsStr := l.colors.Timestamp().Sprintf("[%s]", timestamp)
2✔
460
        actionStr := l.colors.Info().Sprintf("DRAFT REVIEW: %s", action)
2✔
461
        l.writeStdout("%s %s\n", tsStr, actionStr)
2✔
462

2✔
463
        if feedback != "" {
3✔
464
                l.writeFile("[%s] FEEDBACK: %s\n", timestamp, feedback)
1✔
465
                feedbackStr := l.colors.Info().Sprintf("FEEDBACK: %s", feedback)
1✔
466
                l.writeStdout("%s %s\n", tsStr, feedbackStr)
1✔
467
        }
1✔
468
}
469

470
// Elapsed returns formatted elapsed time since start.
471
func (l *Logger) Elapsed() string {
24✔
472
        return humanize.RelTime(l.startTime, time.Now(), "", "")
24✔
473
}
24✔
474

475
// Close writes footer, releases the file lock, and closes the progress file.
476
func (l *Logger) Close() error {
23✔
477
        if l.file == nil {
23✔
UNCOV
478
                return nil
×
UNCOV
479
        }
×
480

481
        l.writeFile("\n%s\n", strings.Repeat("-", 60))
23✔
482
        l.writeFile("Completed: %s (%s)\n", time.Now().Format("2006-01-02 15:04:05"), l.Elapsed())
23✔
483

23✔
484
        // release file lock before closing
23✔
485
        _ = unlockFile(l.file)
23✔
486
        unregisterActiveLock(l.file.Name())
23✔
487

23✔
488
        if err := l.file.Close(); err != nil {
23✔
UNCOV
489
                return fmt.Errorf("close progress file: %w", err)
×
UNCOV
490
        }
×
491
        return nil
23✔
492
}
493

494
func (l *Logger) writeFile(format string, args ...any) {
203✔
495
        if l.file != nil {
406✔
496
                fmt.Fprintf(l.file, format, args...)
203✔
497
        }
203✔
498
}
499

500
func (l *Logger) writeStdout(format string, args ...any) {
19✔
501
        fmt.Fprintf(l.stdout, format, args...)
19✔
502
}
19✔
503

504
// getProgressFilename returns progress file path based on plan and mode.
505
func progressFilename(planFile, planDescription, mode string) string {
34✔
506
        // plan mode uses sanitized plan description
34✔
507
        if mode == "plan" && planDescription != "" {
42✔
508
                sanitized := sanitizePlanName(planDescription)
8✔
509
                return fmt.Sprintf("progress-plan-%s.txt", sanitized)
8✔
510
        }
8✔
511

512
        if planFile != "" {
33✔
513
                stem := strings.TrimSuffix(filepath.Base(planFile), ".md")
7✔
514
                switch mode {
7✔
515
                case "codex-only":
2✔
516
                        return fmt.Sprintf("progress-%s-codex.txt", stem)
2✔
517
                case "review":
2✔
518
                        return fmt.Sprintf("progress-%s-review.txt", stem)
2✔
519
                default:
3✔
520
                        return fmt.Sprintf("progress-%s.txt", stem)
3✔
521
                }
522
        }
523

524
        switch mode {
19✔
525
        case "codex-only":
2✔
526
                return "progress-codex.txt"
2✔
527
        case "review":
2✔
528
                return "progress-review.txt"
2✔
529
        case "plan":
2✔
530
                return "progress-plan.txt"
2✔
531
        default:
13✔
532
                return "progress.txt"
13✔
533
        }
534
}
535

536
// sanitizePlanName converts plan description to a safe filename component.
537
// replaces spaces with dashes, removes special characters, and limits length.
538
func sanitizePlanName(desc string) string {
19✔
539
        // lowercase and replace spaces with dashes
19✔
540
        result := strings.ToLower(desc)
19✔
541
        result = strings.ReplaceAll(result, " ", "-")
19✔
542

19✔
543
        // keep only alphanumeric and dashes
19✔
544
        var clean strings.Builder
19✔
545
        for _, r := range result {
331✔
546
                if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '-' {
613✔
547
                        clean.WriteRune(r)
301✔
548
                }
301✔
549
        }
550
        result = clean.String()
19✔
551

19✔
552
        // collapse multiple dashes
19✔
553
        for strings.Contains(result, "--") {
22✔
554
                result = strings.ReplaceAll(result, "--", "-")
3✔
555
        }
3✔
556

557
        // trim leading/trailing dashes
558
        result = strings.Trim(result, "-")
19✔
559

19✔
560
        // limit length to 50 characters
19✔
561
        if len(result) > 50 {
21✔
562
                result = result[:50]
2✔
563
                // don't end with a dash
2✔
564
                result = strings.TrimRight(result, "-")
2✔
565
        }
2✔
566

567
        if result == "" {
21✔
568
                return "unnamed"
2✔
569
        }
2✔
570
        return result
17✔
571
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc