-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathschema.resolvers.go
726 lines (617 loc) · 23.5 KB
/
schema.resolvers.go
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
package graph
// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
import (
"context"
"github.com/neel1996/gitconvex-server/api"
"github.com/neel1996/gitconvex-server/git"
"github.com/neel1996/gitconvex-server/global"
"github.com/neel1996/gitconvex-server/graph/generated"
"github.com/neel1996/gitconvex-server/graph/model"
)
func (r *mutationResolver) AddRepo(ctx context.Context, repoName string, repoPath string, cloneSwitch bool, repoURL *string, initSwitch bool, authOption string, sshKeyPath *string, userName *string, password *string) (*model.AddRepoParams, error) {
var addRepoObject api.AddRepoInterface
addRepoObject = api.AddRepoInputs{
RepoName: repoName,
RepoPath: repoPath,
CloneSwitch: cloneSwitch,
RepoURL: *repoURL,
InitSwitch: initSwitch,
AuthOption: authOption,
UserName: *userName,
Password: *password,
SSHKeyPath: *sshKeyPath,
}
return addRepoObject.AddRepo(), nil
}
func (r *mutationResolver) AddBranch(ctx context.Context, repoID string, branchName string) (string, error) {
logger.Log("Initiating branch addition request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if repo.GitRepo == nil {
logger.Log("Repo is invalid. Branch addition failed", global.StatusError)
return global.BranchAddError, nil
}
var addBranchObj git.AddBranchInterface
addBranchObj = git.AddBranchInput{
Repo: repo.GitRepo,
BranchName: branchName,
}
return addBranchObj.AddBranch(), nil
}
func (r *mutationResolver) CheckoutBranch(ctx context.Context, repoID string, branchName string) (string, error) {
logger.Log("Initiating branch checkout request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repository is invalid or HEAD is null", global.StatusError)
return global.BranchCheckoutError, nil
}
var checkoutObject git.BranchCheckoutInterface
checkoutObject = git.BranchCheckoutInputs{
Repo: repo.GitRepo,
BranchName: branchName,
}
return checkoutObject.CheckoutBranch(), nil
}
func (r *mutationResolver) DeleteBranch(ctx context.Context, repoID string, branchName string, forceFlag bool) (*model.BranchDeleteStatus, error) {
logger.Log("Initiating branch deletion request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is null", global.StatusError)
return &model.BranchDeleteStatus{
Status: global.BranchDeleteError,
}, nil
}
var deleteBranchObject git.DeleteBranchInterface
deleteBranchObject = git.DeleteBranchInputs{
Repo: repo.GitRepo,
BranchName: branchName,
}
return deleteBranchObject.DeleteBranch(), nil
}
func (r *mutationResolver) FetchFromRemote(ctx context.Context, repoID string, remoteURL *string, remoteBranch *string) (*model.FetchResult, error) {
logger.Log("Initiating fetch from remote request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if repo.GitRepo == nil {
logger.Log("Repo is invalid", global.StatusError)
return &model.FetchResult{
Status: global.FetchFromRemoteError,
FetchedItems: nil,
}, nil
}
var remoteDataObject git.RemoteDataInterface
remoteDataObject = git.RemoteDataStruct{
Repo: repo.GitRepo,
RemoteURL: *remoteURL,
}
var fetchObject git.FetchInterface
fetchObject = git.FetchStruct{
Repo: repo.GitRepo,
RemoteName: remoteDataObject.GetRemoteName(),
RepoPath: repo.RepoPath,
RemoteURL: *remoteURL,
RemoteBranch: *remoteBranch,
RepoName: repo.RepoName,
AuthOption: repo.AuthOption,
UserName: repo.UserName,
Password: repo.Password,
SSHKeyPath: repo.SSHKeyPath,
}
return fetchObject.FetchFromRemote(), nil
}
func (r *mutationResolver) PullFromRemote(ctx context.Context, repoID string, remoteURL *string, remoteBranch *string) (*model.PullResult, error) {
logger.Log("Initiating pull from remote request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid", global.StatusError)
return &model.PullResult{
Status: global.PullFromRemoteError,
PulledItems: nil,
}, nil
}
var pullObject git.PullInterface
pullObject = git.PullStruct{
Repo: repo.GitRepo,
RemoteURL: *remoteURL,
RemoteBranch: *remoteBranch,
RepoPath: repo.RepoPath,
RepoName: repo.RepoName,
AuthOption: repo.AuthOption,
UserName: repo.UserName,
Password: repo.Password,
SSHKeyPath: repo.SSHKeyPath,
}
return pullObject.PullFromRemote(), nil
}
func (r *mutationResolver) StageItem(ctx context.Context, repoID string, item string) (string, error) {
logger.Log("Initiating stage item request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if repo.GitRepo == nil {
logger.Log("Repo is invalid", global.StatusError)
return global.StageItemError, nil
}
var stageItemObject git.StageItemInterface
stageItemObject = git.StageItemStruct{
Repo: repo.GitRepo,
FileItem: item,
}
return stageItemObject.StageItem(), nil
}
func (r *mutationResolver) RemoveStagedItem(ctx context.Context, repoID string, item string) (string, error) {
logger.Log("Initiating remove item request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if repo.GitRepo == nil {
logger.Log("Repo is invalid", global.StatusError)
return global.RemoveItemError, nil
}
var resetObject git.ResetInterface
resetObject = git.ResetStruct{
Repo: repo.GitRepo,
RepoPath: repo.RepoPath,
FileItem: item,
}
return resetObject.RemoveItem(), nil
}
func (r *mutationResolver) RemoveAllStagedItem(ctx context.Context, repoID string) (string, error) {
logger.Log("Initiating remove all items request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if repo.GitRepo == nil {
logger.Log("Repo is invalid", global.StatusError)
return global.RemoveAllItemsError, nil
}
var resetAllObject git.ResetAllInterface
resetAllObject = git.ResetAllStruct{Repo: repo.GitRepo}
return resetAllObject.ResetAllItems(), nil
}
func (r *mutationResolver) StageAllItems(ctx context.Context, repoID string) (string, error) {
logger.Log("Initiating stage all items request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if repo.GitRepo == nil {
logger.Log("Repo is invalid", global.StatusError)
return global.StageAllItemsError, nil
}
var stageAllObject git.StageAllInterface
stageAllObject = git.StageAllStruct{Repo: repo.GitRepo}
return stageAllObject.StageAllItems(), nil
}
func (r *mutationResolver) CommitChanges(ctx context.Context, repoID string, commitMessage string) (string, error) {
logger.Log("Initiating commit changes request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
var commitObject git.CommitInterface
commitObject = git.CommitStruct{
Repo: repo.GitRepo,
CommitMessage: commitMessage,
RepoPath: repo.RepoPath,
}
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or worktree is null", global.StatusError)
return global.CommitChangeError, nil
}
return commitObject.CommitChanges(), nil
}
func (r *mutationResolver) PushToRemote(ctx context.Context, repoID string, remoteHost string, branch string) (string, error) {
logger.Log("Initiating push to remote request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
var remoteDataObject git.RemoteDataInterface
remoteDataObject = git.RemoteDataStruct{
Repo: repo.GitRepo,
RemoteURL: remoteHost,
}
remoteName := remoteDataObject.GetRemoteName()
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil || remoteName == "" {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return global.PushToRemoteError, nil
}
var pushObject git.PushInterface
pushObject = git.PushStruct{
Repo: repo.GitRepo,
RepoName: repo.RepoName,
AuthOption: repo.AuthOption,
UserName: repo.UserName,
Password: repo.Password,
SSHKeyPath: repo.SSHKeyPath,
RemoteName: remoteName,
RemoteBranch: branch,
RepoPath: repo.RepoPath,
}
return pushObject.PushToRemote(), nil
}
func (r *mutationResolver) SettingsEditPort(ctx context.Context, newPort string) (string, error) {
logger.Log("Initiating update port number request", global.StatusInfo)
return api.UpdatePortNumber(newPort), nil
}
func (r *mutationResolver) UpdateRepoDataFile(ctx context.Context, newDbFile string) (string, error) {
logger.Log("Initiating update data file request", global.StatusInfo)
return api.UpdateDBFilePath(newDbFile), nil
}
func (r *mutationResolver) DeleteRepo(ctx context.Context, repoID string) (*model.DeleteStatus, error) {
logger.Log("Initiating delete repo request", global.StatusInfo)
return api.DeleteRepo(repoID), nil
}
func (r *mutationResolver) UpdateRepoName(ctx context.Context, repoID string, repoName string) (string, error) {
logger.Log("Initiating repo name update request", global.StatusInfo)
return api.UpdateRepoName(repoID, repoName)
}
func (r *mutationResolver) AddRemote(ctx context.Context, repoID string, remoteName string, remoteURL string) (*model.RemoteMutationResult, error) {
logger.Log("Initiating remote addition request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if repo.GitRepo == nil {
logger.Log("Repo is invalid", global.StatusError)
return &model.RemoteMutationResult{Status: global.RemoteAddError}, nil
}
var addRemoteObject git.AddRemoteInterface
addRemoteObject = git.AddRemoteStruct{
Repo: repo.GitRepo,
RemoteName: remoteName,
RemoteURL: remoteURL,
}
return addRemoteObject.AddRemote(), nil
}
func (r *mutationResolver) DeleteRemote(ctx context.Context, repoID string, remoteName string) (*model.RemoteMutationResult, error) {
logger.Log("Initiating remote deletion request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if repo.GitRepo == nil {
logger.Log("Repo is invalid", global.StatusError)
return &model.RemoteMutationResult{Status: global.RemoteAddError}, nil
}
var addRemoteObject git.DeleteRemoteInterface
addRemoteObject = &git.DeleteRemoteStruct{
Repo: repo.GitRepo,
RemoteName: remoteName,
}
return addRemoteObject.DeleteRemote(), nil
}
func (r *mutationResolver) EditRemote(ctx context.Context, repoID string, remoteName string, remoteURL string) (*model.RemoteMutationResult, error) {
logger.Log("Initiating remote edit request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if repo.GitRepo == nil {
logger.Log("Repo is invalid", global.StatusError)
return &model.RemoteMutationResult{Status: global.RemoteEditError}, nil
}
var editRemoteObject git.RemoteEditInterface
editRemoteObject = git.RemoteEditStruct{
Repo: repo.GitRepo,
RemoteName: remoteName,
RemoteUrl: remoteURL,
}
return editRemoteObject.EditRemoteUrl(), nil
}
func (r *queryResolver) HealthCheck(ctx context.Context) (*model.HealthCheckParams, error) {
logger.Log("Initiating health check request", global.StatusInfo)
return api.HealthCheckApi(), nil
}
func (r *queryResolver) FetchRepo(ctx context.Context) (*model.FetchRepoParams, error) {
logger.Log("Initiating fetch repo request", global.StatusInfo)
return api.FetchRepo(), nil
}
func (r *queryResolver) GitRepoStatus(ctx context.Context, repoID string) (*model.GitRepoStatusResults, error) {
logger.Log("Initiating repo status request", global.StatusInfo)
return api.RepoStatus(repoID), nil
}
func (r *queryResolver) GitFolderContent(ctx context.Context, repoID string, directoryName *string) (*model.GitFolderContentResults, error) {
logger.Log("Initiating get folder content request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return &model.GitFolderContentResults{
TrackedFiles: nil,
FileBasedCommits: nil,
}, nil
}
tmp := &model.GitFolderContentResults{}
tmp.FileBasedCommits = nil
tmp.TrackedFiles = nil
var listFileObject git.ListFilesInterface
listFileObject = git.ListFilesStruct{
Repo: repo.GitRepo,
RepoPath: repo.RepoPath,
DirectoryName: *directoryName,
FileName: nil,
}
return listFileObject.ListFiles(), nil
}
func (r *queryResolver) GitCommitLogs(ctx context.Context, repoID string, referenceCommit string) (*model.GitCommitLogResults, error) {
logger.Log("Initiating get commit logs request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
var commitLogObject git.CommitLogInterface
commitLogObject = git.CommitLogStruct{
Repo: repo.GitRepo,
ReferenceCommit: referenceCommit,
}
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return &model.GitCommitLogResults{
TotalCommits: nil,
Commits: nil,
}, nil
}
return commitLogObject.CommitLogs(), nil
}
func (r *queryResolver) GitCommitFiles(ctx context.Context, repoID string, commitHash string) ([]*model.GitCommitFileResult, error) {
logger.Log("Initiating get commit files request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
var commitFileListObject git.CommitFileListInterface
commitFileListObject = git.CommitFileListStruct{
Repo: repo.GitRepo,
CommitHash: commitHash,
}
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return []*model.GitCommitFileResult{
{
Type: "",
FileName: "",
},
}, nil
}
return commitFileListObject.CommitFileList(), nil
}
func (r *queryResolver) SearchCommitLogs(ctx context.Context, repoID string, searchType string, searchKey string) ([]*model.GitCommits, error) {
logger.Log("Initiating search commit logs request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
var searchCommitObject git.SearchCommitInterface
searchCommitObject = git.SearchCommitStruct{
Repo: repo.GitRepo,
SearchType: searchType,
SearchKey: searchKey,
}
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return []*model.GitCommits{
{
Hash: nil,
Author: nil,
CommitTime: nil,
CommitMessage: nil,
CommitFilesCount: nil,
},
}, nil
}
return searchCommitObject.SearchCommitLogs(), nil
}
func (r *queryResolver) CodeFileDetails(ctx context.Context, repoID string, fileName string) (*model.CodeFileType, error) {
logger.Log("Initiating code file view request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return &model.CodeFileType{
FileData: nil,
}, nil
}
var codeFileViewObject api.CodeViewInterface
codeFileViewObject = api.CodeViewInputs{
RepoPath: repo.RepoPath,
FileName: fileName,
}
return codeFileViewObject.CodeFileView(), nil
}
func (r *queryResolver) GitChanges(ctx context.Context, repoID string) (*model.GitChangeResults, error) {
logger.Log("Initiating repo changes request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
var gitChangeObject git.ChangedItemsInterface
if repo.GitRepo == nil {
logger.Log("Repo is invalid", global.StatusError)
return &model.GitChangeResults{
GitUntrackedFiles: nil,
GitChangedFiles: nil,
GitStagedFiles: nil,
}, nil
}
gitChangeObject = git.ChangedItemStruct{
Repo: repo.GitRepo,
RepoPath: repo.RepoPath,
}
return gitChangeObject.ChangedFiles(), nil
}
func (r *queryResolver) GitUnPushedCommits(ctx context.Context, repoID string, remoteURL string, remoteBranch string) (*model.UnPushedCommitResult, error) {
logger.Log("Initiating get un-pushed commits request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return nil, nil
}
var remoteDataObject git.RemoteDataInterface
remoteDataObject = git.RemoteDataStruct{
Repo: repo.GitRepo,
RemoteURL: remoteURL,
}
remoteName := remoteDataObject.GetRemoteName()
remoteRef := remoteName + "/" + remoteBranch
var unPushedObject git.UnPushedCommitInterface
unPushedObject = git.UnPushedCommitStruct{
Repo: repo.GitRepo,
RemoteRef: remoteRef,
LocalRef: remoteBranch,
}
return unPushedObject.UnPushedCommits(), nil
}
func (r *queryResolver) GitFileLineChanges(ctx context.Context, repoID string, fileName string) (*model.FileLineChangeResult, error) {
logger.Log("Initiating get line by line diff request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return &model.FileLineChangeResult{
DiffStat: "",
FileDiff: nil,
}, nil
}
var codeFileViewObject api.CodeViewInterface
codeFileViewObject = api.CodeViewInputs{
RepoPath: repo.RepoPath,
FileName: fileName,
}
fileContent := codeFileViewObject.CodeFileView()
var fileLineDiffObject git.FileLineDiffInterface
fileLineDiffObject = git.FileLineDiffStruct{
Repo: repo.GitRepo,
FileName: fileName,
Data: fileContent.FileData,
}
return fileLineDiffObject.FileLineDiff(), nil
}
func (r *queryResolver) SettingsData(ctx context.Context) (*model.SettingsDataResults, error) {
logger.Log("Initiating get settings data request", global.StatusInfo)
return api.GetSettingsData(), nil
}
func (r *queryResolver) CommitCompare(ctx context.Context, repoID string, baseCommit string, compareCommit string) ([]*model.GitCommitFileResult, error) {
logger.Log("Initiating compare commit request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return []*model.GitCommitFileResult{
{
Type: "",
FileName: "",
},
}, nil
}
var compareCommitObject git.CompareCommitInterface
compareCommitObject = git.CompareCommitStruct{
Repo: repo.GitRepo,
BaseCommitString: baseCommit,
CompareCommitString: compareCommit,
}
return compareCommitObject.CompareCommit(), nil
}
func (r *queryResolver) BranchCompare(ctx context.Context, repoID string, baseBranch string, compareBranch string) ([]*model.BranchCompareResults, error) {
logger.Log("Initiating compare branch request", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
if head, _ := repo.GitRepo.Head(); repo.GitRepo == nil || head == nil {
logger.Log("Repo is invalid or HEAD is nil", global.StatusError)
return []*model.BranchCompareResults{
{
Date: "",
Commits: nil,
},
}, nil
}
var branchCompareObject git.BranchCompareInterface
branchCompareObject = git.BranchCompareInputs{
Repo: repo.GitRepo,
BaseBranch: baseBranch,
DiffBranch: compareBranch,
}
return branchCompareObject.CompareBranch(), nil
}
func (r *queryResolver) GetRemote(ctx context.Context, repoID string) ([]*model.RemoteDetails, error) {
logger.Log("Initating remote data fetching", global.StatusInfo)
repoChan := make(chan git.RepoDetails)
var repoObject git.RepoInterface
repoObject = git.RepoStruct{RepoId: repoID}
go repoObject.Repo(repoChan)
repo := <-repoChan
var remoteObject git.RemoteDataInterface
remoteObject = git.RemoteDataStruct{
Repo: repo.GitRepo,
}
allRemoteData := remoteObject.GetAllRemotes()
return allRemoteData, nil
}
// Mutation returns generated.MutationResolver implementation.
func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} }
// Query returns generated.QueryResolver implementation.
func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} }
type mutationResolver struct{ *Resolver }
type queryResolver struct{ *Resolver }
// !!! WARNING !!!
// The code below was going to be deleted when updating resolvers. It has been copied here so you have
// one last chance to move it out of harms way if you want. There are two reasons this happens:
// - When renaming or deleting a resolver the old code will be put in here. You can safely delete
// it when you're done.
// - You have helper methods in this file. Move them out to keep these resolver files clean.
var logger global.Logger