-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.go
More file actions
748 lines (688 loc) · 19.5 KB
/
Copy pathinit.go
File metadata and controls
748 lines (688 loc) · 19.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
)
func runInit() {
fmt.Println()
c := loadConfig()
proj := loadProjectConfig()
if proj.effectivePrimary() != "" {
handleConfiguredRepo(proj, c)
return
}
platform := proj.platform
if platform == "" {
fmt.Println(" which platform is this repo on?")
fmt.Println()
fmt.Println(" 1 github")
fmt.Println(" 2 gitlab")
fmt.Println(" 3 gitea")
fmt.Println(" 4 forgejo")
fmt.Println()
fmt.Printf(" [1/2/3/4] pick › ")
for {
switch strings.TrimSpace(readLine()) {
case "1":
platform = "github"
case "2":
platform = "gitlab"
case "3":
platform = "gitea"
case "4":
platform = "forgejo"
default:
fmt.Printf(" [1/2/3/4] pick › ")
continue
}
break
}
fmt.Println()
proj.platform = platform
_ = saveProjectConfig(proj)
}
token := tokenForPlatform(c, platform)
if token == "" {
fatal("no token found for %s. run 'commitdog setup' first.", platform)
}
fmt.Printf(" connecting to %s...", platform)
username, err := platformUsername(c, platform)
if err != nil {
fmt.Println()
fatal("could not connect to %s: %v\nrun 'commitdog setup' to update your token.", platform, err)
}
fmt.Printf("\n ✓ connected as %s\n\n", username)
orgs, _ := platformOrgs(c, platform)
destinations := []string{username + " (personal)"}
for _, o := range orgs {
destinations = append(destinations, o)
}
var owner string
if len(destinations) == 1 {
owner = username
fmt.Printf(" creating under %s\n\n", username)
} else {
fmt.Println(" where to create the repo?")
for i, d := range destinations {
fmt.Printf(" %d %s\n", i+1, d)
}
fmt.Println()
fmt.Printf(" [1-%d] pick › ", len(destinations))
for {
input := strings.TrimSpace(readLine())
idx := 0
for _, r := range input {
if r >= '1' && r <= '9' {
idx = int(r-'0') - 1
break
}
}
if idx >= 0 && idx < len(destinations) {
if idx == 0 {
owner = username
} else {
owner = orgs[idx-1]
}
break
}
fmt.Printf(" [1-%d] pick › ", len(destinations))
}
}
defaultName := filepath.Base(getCurrentDir())
fmt.Printf(" repo name [%s] › ", defaultName)
repoName := sanitizeInput(readLine())
if repoName == "" {
repoName = defaultName
}
if !isSafeRepoName(repoName) {
fatal("invalid repo name: %s", repoName)
}
fmt.Printf(" private or public? [P/u] › ")
private := true
for {
input := strings.ToLower(sanitizeInput(readLine()))
if input == "" || input == "p" {
private = true
break
}
if input == "u" {
private = false
break
}
fmt.Printf(" P or u › ")
}
fmt.Printf("\n creating repo...")
repo, err := platformCreateRepo(c, platform, owner, username, repoName, private)
if err != nil {
fmt.Println()
errMsg := err.Error()
if strings.Contains(errMsg, "already exists") {
fatal("repo %s/%s already exists on %s.", owner, repoName, platform)
}
fatal("failed to create repo: %v", err)
}
fmt.Printf("\n ✓ repo created: %s\n\n", repo.HTMLURL)
if err := gitInit(); err != nil {
fatal("git init failed: %v", err)
}
remoteURL := repo.SSHURL
if !hasSSHKey(sshHostForPlatform(c, platform)) {
remoteURL = strings.TrimSuffix(repo.HTMLURL, ".git") + ".git"
}
if err := gitSetRemote("origin", remoteURL); err != nil {
fatal("failed to set remote: %v", err)
}
fmt.Printf(" ✓ remote set to %s\n", remoteURL)
if err := gitAddAll(); err != nil {
fatal("git add failed: %v", err)
}
diff, _ := getStagedDiff()
if diff == "" {
fmt.Println(" nothing to commit. add some files first.")
return
}
suggestions := []string{
"feat: initial commit",
"chore: initial project setup",
"init: bootstrap " + repoName,
}
chosen := pickSuggestion(suggestions)
if chosen == "" {
fmt.Println(" aborted.")
return
}
if err := runCommit(chosen); err != nil {
fatal("commit failed: %v", err)
}
fmt.Printf("\n ✓ committed: %s\n", chosen)
fmt.Printf("\n pushing...")
authHeader := authHeaderForPlatform(token)
if err := runPushWithAuth("origin", "main", authHeader); err != nil {
if err2 := runPushWithAuth("origin", "master", authHeader); err2 != nil {
fmt.Printf("\n push failed: %s\n", err)
return
}
}
fmt.Printf("\n ✓ pushed\n")
fmt.Printf("\n live at %s\n\n", repo.HTMLURL)
}
func platformUsername(c config, platform string) (string, error) {
token := tokenForPlatform(c, platform)
switch platform {
case "gitlab":
return getGitLabUsername(token, gitlabHost(c))
case "gitea":
return getGiteaUsername(token, c.Gitea.Host)
case "forgejo":
return getForgejoUsername(token, c.Forgejo.Host)
default:
return getGitHubUsername(token)
}
}
func platformOrgs(c config, platform string) ([]string, error) {
token := tokenForPlatform(c, platform)
switch platform {
case "gitlab":
return getGitLabGroups(token, gitlabHost(c))
case "gitea":
return getGiteaOrgs(token, c.Gitea.Host)
case "forgejo":
return getForgejoOrgs(token, c.Forgejo.Host)
default:
return getGitHubOrgs(token)
}
}
func platformCreateRepo(c config, platform, owner, username, name string, private bool) (repoResponse, error) {
token := tokenForPlatform(c, platform)
switch platform {
case "gitlab":
host := gitlabHost(c)
if owner == username {
return createGitLabRepo(token, host, name, private)
}
return createGitLabGroupRepo(token, host, owner, name, private)
case "gitea":
if owner == username {
return createGiteaRepo(token, c.Gitea.Host, name, private)
}
return createGiteaOrgRepo(token, c.Gitea.Host, owner, name, private)
case "forgejo":
if owner == username {
return createForgejoRepo(token, c.Forgejo.Host, name, private)
}
return createForgejoOrgRepo(token, c.Forgejo.Host, owner, name, private)
default:
if owner == username {
return createPersonalRepo(token, name, private)
}
return createOrgRepo(token, owner, name, private)
}
}
func getCurrentDir() string {
dir, err := os.Getwd()
if err != nil {
return "my-project"
}
return dir
}
func isSafeRepoName(s string) bool {
if s == "" || len(s) > 100 {
return false
}
for _, c := range s {
if !isAlphanumeric(c) && c != '-' && c != '_' && c != '.' {
return false
}
}
return true
}
func handleConfiguredRepo(proj projectConfig, c config) {
primary := proj.effectivePrimary()
fmt.Println()
fmt.Printf(" this repo is configured for %s.\n", primary)
if len(proj.mirrors) > 0 {
fmt.Printf(" mirrors: %s\n", strings.Join(proj.mirrors, ", "))
}
fmt.Println()
fmt.Println(" 1 change platform")
fmt.Println(" 2 add mirror")
if len(proj.mirrors) > 0 {
fmt.Println(" 3 remove mirror")
fmt.Println(" 4 cancel")
fmt.Println()
fmt.Printf(" [1/2/3/4] pick › ")
} else {
fmt.Println(" 3 cancel")
fmt.Println()
fmt.Printf(" [1/2/3] pick › ")
}
switch strings.TrimSpace(readLine()) {
case "1":
changePrimaryPlatform(proj)
case "2":
addMirrorPlatform(proj, c)
case "3":
if len(proj.mirrors) > 0 {
removeMirrorPlatform(proj)
} else {
fmt.Println(" cancelled.")
}
case "4":
fmt.Println(" cancelled.")
default:
fmt.Println(" cancelled.")
}
}
func changePrimaryPlatform(proj projectConfig) {
all := []string{"github", "gitlab", "gitea", "forgejo"}
fmt.Println()
fmt.Println(" select new primary platform:")
fmt.Println()
for i, p := range all {
fmt.Printf(" %d %s\n", i+1, p)
}
fmt.Println()
fmt.Printf(" [1-%d] pick, [q] quit › ", len(all))
for {
input := strings.TrimSpace(readLine())
if input == "q" || input == "" {
fmt.Println(" cancelled.")
return
}
for i, newPrimary := range all {
if input == fmt.Sprintf("%d", i+1) {
cfg := loadConfig()
if tokenForPlatform(cfg, newPrimary) == "" {
fmt.Println()
fmt.Printf(" %s %s is not configured — no token found.\n\n", colorYellow("⚠"), newPrimary)
fmt.Printf(" configure %s now? [Y/n] › ", newPrimary)
ans := strings.ToLower(strings.TrimSpace(readLine()))
if ans == "n" || ans == "no" {
fmt.Println(" cancelled.")
return
}
runSetup()
cfg = loadConfig()
if tokenForPlatform(cfg, newPrimary) == "" {
fmt.Printf(" %s no token saved for %s — cancelled.\n\n", colorRed("✗"), newPrimary)
return
}
}
oldPrimary := proj.effectivePrimary()
proj.primary = newPrimary
proj.platform = newPrimary
if oldPrimary != "" && oldPrimary != newPrimary {
alreadyMirror := false
for _, m := range proj.mirrors {
if m == oldPrimary {
alreadyMirror = true
break
}
}
if !alreadyMirror {
proj.mirrors = append(proj.mirrors, oldPrimary)
}
}
var filtered []string
for _, m := range proj.mirrors {
if m != newPrimary {
filtered = append(filtered, m)
}
}
proj.mirrors = filtered
if err := saveProjectConfig(proj); err != nil {
fatal("could not update .commitdog: %v", err)
}
newRemote := platformRemoteName(newPrimary)
newURL := ""
if newRemote != "origin" && remoteExists(newRemote) {
cmd := exec.Command("git", "remote", "get-url", newRemote)
var out strings.Builder
cmd.Stdout = &out
if err := cmd.Run(); err == nil {
newURL = strings.TrimSpace(out.String())
}
}
if newURL == "" {
_, repoName := getRepoOwnerAndName()
if repoName == "" {
if cwd, err := os.Getwd(); err == nil {
if idx := strings.LastIndex(cwd, "/"); idx >= 0 {
repoName = cwd[idx+1:]
}
}
}
if repoName != "" {
newURL, _ = buildOriginURL(newPrimary, repoName, cfg)
if newURL == "" {
newURL, _ = fetchRepoCloneURL(newPrimary, repoName, cfg)
}
if newURL == "" {
fmt.Printf(" %s repo not found on %s — you may need to create it first\n", colorYellow("⚠"), newPrimary)
fmt.Printf(" 1 create repo on %s now\n", newPrimary)
fmt.Println(" 2 continue anyway")
fmt.Println()
fmt.Printf(" [1/2] pick › ")
if strings.TrimSpace(readLine()) == "1" {
fmt.Println()
runInit()
return
}
}
}
}
if newURL != "" {
exec.Command("git", "remote", "set-url", "origin", newURL).Run()
fmt.Printf(" %s origin → %s\n", colorGreen("✓"), newURL)
}
fmt.Printf(" %s primary platform changed to %s\n\n", colorGreen("✓"), newPrimary)
return
}
}
fmt.Printf(" 1-%d or q › ", len(all))
}
}
func addMirrorPlatform(proj projectConfig, c config) {
primary := proj.effectivePrimary()
all := []string{"github", "gitlab", "gitea", "forgejo"}
var available []string
for _, p := range all {
if p == primary {
continue
}
already := false
for _, m := range proj.mirrors {
if m == p {
already = true
break
}
}
if !already {
available = append(available, p)
}
}
if len(available) == 0 {
fmt.Println(" all platforms are already configured.")
return
}
fmt.Println()
fmt.Println(" add which platform as mirror?")
fmt.Println()
for i, p := range available {
fmt.Printf(" %d %s\n", i+1, p)
}
fmt.Println()
fmt.Printf(" [1-%d] pick, [q] quit › ", len(available))
var mirrorPlatform string
for {
input := strings.TrimSpace(readLine())
if input == "q" || input == "" {
fmt.Println(" cancelled.")
return
}
for i, p := range available {
if input == fmt.Sprintf("%d", i+1) {
mirrorPlatform = p
break
}
}
if mirrorPlatform != "" {
break
}
fmt.Printf(" 1-%d or q › ", len(available))
}
token := tokenForPlatform(c, mirrorPlatform)
if token == "" {
fatal("no token for %s. run 'commitdog setup' first.", mirrorPlatform)
}
fmt.Printf(" connecting to %s...", mirrorPlatform)
username, err := platformUsername(c, mirrorPlatform)
if err != nil {
fmt.Println()
fatal("could not connect to %s: %v", mirrorPlatform, err)
}
fmt.Printf("\n ✓ connected as %s\n\n", username)
owner := username
orgs, _ := platformOrgs(c, mirrorPlatform)
if len(orgs) > 0 {
fmt.Println(" where to create the repo?")
fmt.Println()
fmt.Printf(" 1 %s (personal)\n", username)
for i, org := range orgs {
fmt.Printf(" %d %s\n", i+2, org)
}
fmt.Println()
fmt.Printf(" [1-%d] pick › ", len(orgs)+1)
for {
inp := strings.TrimSpace(readLine())
if inp == "1" || inp == "" {
break
}
picked := false
for i, org := range orgs {
if inp == fmt.Sprintf("%d", i+2) {
owner = org
picked = true
break
}
}
if picked {
break
}
fmt.Printf(" 1-%d › ", len(orgs)+1)
}
fmt.Println()
}
_, currentRepo := getRepoOwnerAndName()
fmt.Printf(" repo name [%s] › ", currentRepo)
input := sanitizeInput(readLine())
if input != "" {
currentRepo = input
}
fmt.Printf(" private or public? [P/u] › ")
private := true
for {
inp := strings.ToLower(sanitizeInput(readLine()))
if inp == "" || inp == "p" {
private = true
break
}
if inp == "u" {
private = false
break
}
fmt.Printf(" P or u › ")
}
fmt.Printf("\n creating repo on %s...", mirrorPlatform)
repo, err := platformCreateRepo(c, mirrorPlatform, owner, username, currentRepo, private)
var remoteURL string
if err != nil {
fmt.Println()
errMsg := strings.ToLower(err.Error())
if strings.Contains(errMsg, "already exists") || strings.Contains(errMsg, "exists") || strings.Contains(errMsg, "repository creation failed") || strings.Contains(errMsg, "name already") {
fmt.Printf(" repo '%s' already exists on %s.\n\n", currentRepo, mirrorPlatform)
fmt.Println(" 1 use existing repo as mirror")
fmt.Println(" 2 choose a different name")
fmt.Println(" 3 cancel")
fmt.Println()
fmt.Printf(" [1/2/3] pick › ")
switch strings.TrimSpace(readLine()) {
case "1":
fmt.Printf(" fetching repo details from %s...", mirrorPlatform)
fetched, ferr := platformCreateRepo(c, mirrorPlatform, owner, username, currentRepo, private)
if ferr == nil && fetched.HTMLURL != "" {
fmt.Println()
fmt.Printf(" found: %s\n", fetched.HTMLURL)
fmt.Printf(" use this repo? [Y/n] › ")
if ans := strings.ToLower(strings.TrimSpace(readLine())); ans != "n" && ans != "no" {
remoteURL = strings.TrimSuffix(fetched.HTMLURL, ".git") + ".git"
} else {
remoteURL = buildMirrorURL(c, mirrorPlatform, owner, currentRepo)
}
} else {
fmt.Println()
remoteURL = buildMirrorURL(c, mirrorPlatform, owner, currentRepo)
}
fmt.Printf(" using %s\n\n", remoteURL)
case "2":
fmt.Printf(" new repo name › ")
newName := sanitizeInput(readLine())
if newName == "" || !isSafeRepoName(newName) {
fmt.Println(" invalid name.")
return
}
currentRepo = newName
fmt.Printf(" creating repo...")
repo, err = platformCreateRepo(c, mirrorPlatform, owner, username, currentRepo, private)
if err != nil {
fmt.Println()
fatal("failed to create repo: %v", err)
}
fmt.Printf("\n ✓ repo created: %s\n\n", repo.HTMLURL)
remoteURL = strings.TrimSuffix(repo.HTMLURL, ".git") + ".git"
default:
fmt.Println(" cancelled.")
return
}
} else {
fatal("failed to create repo: %v", err)
}
} else {
fmt.Printf("\n ✓ repo created: %s\n\n", repo.HTMLURL)
remoteURL = strings.TrimSuffix(repo.HTMLURL, ".git") + ".git"
}
remoteName := platformRemoteName(mirrorPlatform)
if remoteExists(remoteName) {
cmd := exec.Command("git", "remote", "set-url", remoteName, remoteURL)
if err := cmd.Run(); err != nil {
fmt.Printf(" warning: could not update remote URL: %v\n", err)
} else {
fmt.Printf(" %s remote '%s' URL updated\n", colorGreen("✓"), remoteName)
}
} else if err := gitAddRemote(remoteName, remoteURL); err != nil {
fmt.Printf(" could not add remote '%s': %v\n", remoteName, err)
fmt.Printf(" enter remote URL manually (or leave empty to cancel) › ")
manualURL := strings.TrimSpace(readLine())
if manualURL == "" {
fmt.Println(" cancelled.")
return
}
if err2 := gitAddRemote(remoteName, manualURL); err2 != nil {
fmt.Printf(" %s could not add remote: %v\n", colorRed("✗"), err2)
return
}
remoteURL = manualURL
fmt.Printf(" %s remote '%s' added\n", colorGreen("✓"), remoteName)
} else {
fmt.Printf(" %s remote '%s' added\n", colorGreen("✓"), remoteName)
}
proj.mirrors = append(proj.mirrors, mirrorPlatform)
if proj.primary == "" {
proj.primary = primary
}
if err := saveProjectConfig(proj); err != nil {
fmt.Printf(" %s could not update .commitdog: %v\n", colorRed("✗"), err)
} else {
fmt.Printf(" %s .commitdog updated\n", colorGreen("✓"))
}
branch := getCurrentBranch()
authHeader := authHeaderForPlatformName(mirrorPlatform)
fmt.Printf(" pushing to %s...", mirrorPlatform)
if err := runPushUpstreamWithAuth(remoteName, branch, authHeader); err != nil {
fmt.Printf("\n %s push failed: %v\n", colorRed("✗"), err)
platformFlags := map[string]string{"github": "gh", "gitlab": "gl", "gitea": "gt", "forgejo": "fg"}
fmt.Printf(" mirror registered — run 'commitdog -%s' to retry\n\n", platformFlags[mirrorPlatform])
} else {
fmt.Printf("\n %s pushed\n\n", colorGreen("✓"))
}
}
func buildMirrorURL(c config, platform, username, repo string) string {
switch platform {
case "gitlab":
host := gitlabHost(c)
return strings.TrimRight(host, "/") + "/" + username + "/" + repo + ".git"
case "gitea":
return strings.TrimRight(c.Gitea.Host, "/") + "/" + username + "/" + repo + ".git"
case "forgejo":
return strings.TrimRight(c.Forgejo.Host, "/") + "/" + username + "/" + repo + ".git"
default:
return "https://github.com/" + username + "/" + repo + ".git"
}
}
func removeMirrorPlatform(proj projectConfig) {
fmt.Println()
fmt.Println(" remove which mirror?")
fmt.Println()
for i, m := range proj.mirrors {
fmt.Printf(" %d %s\n", i+1, m)
}
fmt.Println()
fmt.Printf(" [1-%d] pick, [q] quit › ", len(proj.mirrors))
var target string
for {
input := strings.TrimSpace(readLine())
if input == "q" || input == "" {
fmt.Println(" cancelled.")
return
}
for i, m := range proj.mirrors {
if input == fmt.Sprintf("%d", i+1) {
target = m
break
}
}
if target != "" {
break
}
fmt.Printf(" 1-%d or q › ", len(proj.mirrors))
}
fmt.Println()
fmt.Printf(" removing %s as a mirror\n\n", target)
fmt.Println(" this will:")
fmt.Println(" · remove the git remote from this repo")
fmt.Println(" · remove " + target + " from .commitdog")
fmt.Println(" · leave the repo on " + target + " untouched")
fmt.Println()
fmt.Printf(" type 'y' to confirm or 'n' to cancel › ")
for {
input := strings.ToLower(strings.TrimSpace(readLine()))
if input == "y" || input == "yes" {
break
}
if input == "n" || input == "no" {
fmt.Println(" cancelled.")
return
}
fmt.Printf(" type 'y' or 'n' › ")
}
fmt.Println()
remoteName := platformRemoteName(target)
repoURL := getRemoteURL(remoteName)
if remoteExists(remoteName) {
if err := exec.Command("git", "remote", "remove", remoteName).Run(); err != nil {
fmt.Printf(" %s could not remove remote '%s'\n", colorRed("✗"), remoteName)
} else {
fmt.Printf(" %s remote '%s' removed\n", colorGreen("✓"), remoteName)
}
}
var updated []string
for _, m := range proj.mirrors {
if m != target {
updated = append(updated, m)
}
}
proj.mirrors = updated
if err := saveProjectConfig(proj); err != nil {
fmt.Printf(" %s could not update .commitdog: %v\n", colorRed("✗"), err)
return
}
fmt.Printf(" %s .commitdog updated\n\n", colorGreen("✓"))
if repoURL != "" {
cleanURL := strings.TrimSuffix(repoURL, ".git")
fmt.Printf(" to delete the repo on %s:\n", target)
fmt.Printf(" → %s/settings\n\n", cleanURL)
}
}