Debian Codegraph @

storage/transactional/reflog.go

raw symbols SCIP
1 package transactionalscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/
2
3 import (
4 "github.com/go-git/go-git/v6/plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/"
5 "github.com/go-git/go-git/v6/plumbing/format/reflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/reflog`/"
6 "github.com/go-git/go-git/v6/plumbing/storerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/"
7 )
8
9 // ReflogStorage implements the storer.ReflogStorer for the transactional package.
10 type ReflogStoragescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage# struct {
11 basescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#base. storerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/.ReflogStorerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#
12 temporalscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#temporal. storerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/.ReflogStorerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#
13
14 // appended tracks refs that had entries appended during the transaction.
15 appendedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#appended. map[plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.ReferenceNamescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/ReferenceName#]struct{}
16 // deleted tracks refs whose reflogs were deleted during the transaction.
17 deletedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#deleted. map[plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.ReferenceNamescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/ReferenceName#]struct{}
18 }
19
20 // NewReflogStorage returns a new ReflogStorage based on a base storer and
21 // a temporal storer.
22 func NewReflogStoragescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/NewReflogStorage().(base, temporal storerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/.ReflogStorerscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#) *ReflogStoragescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage# {
23 return &ReflogStoragescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#{
24 basescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#base.: base,
25 temporalscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#temporal.: temporal,
26 appendedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#appended.: make(map[plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.ReferenceNamescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/ReferenceName#]struct{}),
27 deletedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#deleted.: make(map[plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.ReferenceNamescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/ReferenceName#]struct{}),
28 }
29 }
30
31 // Reflog honors the storer.ReflogStorer interface.
32 // Returns base entries followed by temporal entries. If the reflog was
33 // deleted during this transaction, only temporal entries (if any) are returned.
34 func (s *ReflogStoragescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#) Reflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#Reflog().(name plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.ReferenceNamescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/ReferenceName#) ([]*reflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/reflog`/.Entryscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/reflog`/Entry#, error) {
35 if s == nil {
36 return nil, nil
37 }
38
39 var base []*reflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/reflog`/.Entryscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/reflog`/Entry#
40 if _, ok := s.deletedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#deleted.[name]; !ok {
41 var err error
42 base, err = s.basescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#base..Reflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#Reflog.(name)
43 if err != nil {
44 return nil, err
45 }
46 }
47
48 temporal, err := s.temporalscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#temporal..Reflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#Reflog.(name)
49 if err != nil {
50 return nil, err
51 }
52
53 if len(base) == 0 {
54 return temporal, nil
55 }
56 if len(temporal) == 0 {
57 return base, nil
58 }
59
60 result := make([]*reflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/reflog`/.Entryscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/reflog`/Entry#, 0, len(base)+len(temporal))
61 result = append(result, base...)
62 result = append(result, temporal...)
63 return result, nil
64 }
65
66 // AppendReflog honors the storer.ReflogStorer interface.
67 func (s *ReflogStoragescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#) AppendReflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#AppendReflog().(name plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.ReferenceNamescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/ReferenceName#, entry *reflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/reflog`/.Entryscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/format/reflog`/Entry#) error {
68 if s == nil {
69 return nil
70 }
71 s.appendedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#appended.[name] = struct{}{}
72 return s.temporalscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#temporal..AppendReflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#AppendReflog.(name, entry)
73 }
74
75 // DeleteReflog honors the storer.ReflogStorer interface.
76 func (s *ReflogStoragescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#) DeleteReflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#DeleteReflog().(name plumbingscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/.ReferenceNamescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing`/ReferenceName#) error {
77 if s == nil {
78 return nil
79 }
80 delete(s.appendedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#appended., name)
81 s.deletedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#deleted.[name] = struct{}{}
82 return s.temporalscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#temporal..DeleteReflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#DeleteReflog.(name)
83 }
84
85 // Commit flushes the transactional reflog changes into the base storage.
86 func (s *ReflogStoragescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#) Commitscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#Commit().() error {
87 if s == nil {
88 return nil
89 }
90
91 for name := range s.deletedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#deleted. {
92 if err := s.basescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#base..DeleteReflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#DeleteReflog.(name); err != nil {
93 return err
94 }
95 }
96
97 for name := range s.appendedscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#appended. {
98 entries, err := s.temporalscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#temporal..Reflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#Reflog.(name)
99 if err != nil {
100 return err
101 }
102 for _, e := range entries {
103 if err := s.basescip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/storage/transactional`/ReflogStorage#base..AppendReflogscip-go gomod github.com/go-git/go-git/v6 . `github.com/go-git/go-git/v6/plumbing/storer`/ReflogStorer#AppendReflog.(name, e); err != nil {
104 return err
105 }
106 }
107 }
108
109 return nil
110 }