Skip to content

Commit a0a73af

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
dump dead code
1 parent 1260d96 commit a0a73af

File tree

3 files changed

+3
-76
lines changed

3 files changed

+3
-76
lines changed

pkg/prx/collaborators_cache.go

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -43,45 +43,6 @@ func newCollaboratorsCache(cacheDir string) *collaboratorsCache {
4343
return cc
4444
}
4545

46-
// get retrieves a cached collaborators list if it exists and is not expired.
47-
//
48-
//nolint:unused // Called from graphql_complete.go
49-
func (cc *collaboratorsCache) get(owner, repo string) (map[string]string, bool) {
50-
key := fmt.Sprintf("%s/%s", owner, repo)
51-
52-
cc.mu.RLock()
53-
defer cc.mu.RUnlock()
54-
55-
entry, exists := cc.memory[key]
56-
if !exists {
57-
return nil, false
58-
}
59-
60-
// Check if cache entry is expired
61-
if time.Since(entry.CachedAt) > collaboratorsCacheDuration {
62-
return nil, false
63-
}
64-
65-
return entry.Collaborators, true
66-
}
67-
68-
// set stores a collaborators list in the cache.
69-
//
70-
//nolint:unused // Called from graphql_complete.go
71-
func (cc *collaboratorsCache) set(owner, repo string, collaborators map[string]string) error {
72-
key := fmt.Sprintf("%s/%s", owner, repo)
73-
74-
cc.mu.Lock()
75-
cc.memory[key] = collaboratorsEntry{
76-
Collaborators: collaborators,
77-
CachedAt: time.Now(),
78-
}
79-
cc.mu.Unlock()
80-
81-
// Save to disk after releasing the lock
82-
return cc.saveToDisk()
83-
}
84-
8546
// loadFromDisk loads the cache from disk.
8647
func (cc *collaboratorsCache) loadFromDisk() error {
8748
// Skip if no disk path is set (in-memory only mode)
@@ -114,38 +75,3 @@ func (cc *collaboratorsCache) loadFromDisk() error {
11475

11576
return nil
11677
}
117-
118-
// saveToDisk saves the current cache to disk.
119-
//
120-
//nolint:unused // Called from set()
121-
func (cc *collaboratorsCache) saveToDisk() error {
122-
// Skip if no disk path is set (in-memory only mode)
123-
if cc.diskPath == "" {
124-
return nil
125-
}
126-
127-
// Create a copy to avoid holding the lock during I/O
128-
cc.mu.RLock()
129-
cacheCopy := make(map[string]collaboratorsEntry, len(cc.memory))
130-
for k, v := range cc.memory {
131-
cacheCopy[k] = v
132-
}
133-
cc.mu.RUnlock()
134-
135-
data, err := json.Marshal(cacheCopy)
136-
if err != nil {
137-
return fmt.Errorf("marshaling collaborators cache: %w", err)
138-
}
139-
140-
// Write to temp file first, then rename for atomicity
141-
tempFile := cc.diskPath + ".tmp"
142-
if err := os.WriteFile(tempFile, data, 0o600); err != nil {
143-
return fmt.Errorf("writing collaborators cache: %w", err)
144-
}
145-
146-
if err := os.Rename(tempFile, cc.diskPath); err != nil {
147-
return fmt.Errorf("renaming collaborators cache: %w", err)
148-
}
149-
150-
return nil
151-
}

pkg/prx/graphql_complete.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,8 @@ func (c *Client) convertGraphQLToPullRequest(ctx context.Context, data *graphQLP
10181018
pr.AuthorWriteAccess = c.writeAccessFromAssociation(ctx, owner, repo, data.Author.Login, data.AuthorAssociation)
10191019
}
10201020

1021-
// Assignees
1021+
// Assignees (initialize to empty slice if none)
1022+
pr.Assignees = make([]string, 0)
10221023
for _, assignee := range data.Assignees.Nodes {
10231024
pr.Assignees = append(pr.Assignees, assignee.Login)
10241025
}

pkg/prx/pullrequest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type PullRequest struct {
3939
CheckSummary *CheckSummary `json:"check_summary,omitempty"`
4040
Mergeable *bool `json:"mergeable"`
4141
// 24-byte slice/map fields
42-
Assignees []string `json:"assignees,omitempty"`
42+
Assignees []string `json:"assignees"`
4343
Labels []string `json:"labels,omitempty"`
4444
Reviewers map[string]ReviewState `json:"reviewers,omitempty"`
4545
// 16-byte string fields

0 commit comments

Comments
 (0)