Skip to content

Commit 09adb41

Browse files
committed
added missing function docs
1 parent b99d9ff commit 09adb41

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

config.go

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ func loadConfig(path string, lastModTime time.Time, onChange func(*mirror.RepoPo
8383
return modTime, onChange(newConfig)
8484
}
8585

86+
// ensureConfig will do the diff between current repoPool state and new config
87+
// and based on that diff it will add/remove repositories and worktrees
8688
func ensureConfig(repoPool *mirror.RepoPool, newConfig *mirror.RepoPoolConfig) bool {
8789
success := true
8890

@@ -180,6 +182,8 @@ func parseConfigFile(path string) (*mirror.RepoPoolConfig, error) {
180182
return conf, nil
181183
}
182184

185+
// diffRepositories will do the diff between current state and new config and
186+
// return new repositories config and list of remote url which are not found in config
183187
func diffRepositories(repoPool *mirror.RepoPool, newConfig *mirror.RepoPoolConfig) (
184188
newRepos []mirror.RepositoryConfig,
185189
removedRepos []string,
@@ -206,6 +210,8 @@ func diffRepositories(repoPool *mirror.RepoPool, newConfig *mirror.RepoPoolConfi
206210
return
207211
}
208212

213+
// diffWorktrees will do the diff between current repo's worktree state and new worktree config
214+
// it will return new worktree configs and link names of the link not found in new config
209215
func diffWorktrees(repo *mirror.Repository, newRepoConf *mirror.RepositoryConfig) (
210216
newWTCs []mirror.WorktreeConfig,
211217
removedWTs []string,

pkg/mirror/repo_pool.go

+2
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ func (rp *RepoPool) Repository(remote string) (*Repository, error) {
171171
return nil, ErrNotExist
172172
}
173173

174+
// RepositoriesRemote returns remote URLs of all the repositories
174175
func (rp *RepoPool) RepositoriesRemote() []string {
175176
rp.lock.RLock()
176177
defer rp.lock.RUnlock()
@@ -182,6 +183,7 @@ func (rp *RepoPool) RepositoriesRemote() []string {
182183
return urls
183184
}
184185

186+
// RepositoriesDirPath returns local paths of all the mirrored repositories
185187
func (rp *RepoPool) RepositoriesDirPath() []string {
186188
rp.lock.RLock()
187189
defer rp.lock.RUnlock()

pkg/mirror/repository.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ func (r *Repository) AddWorktreeLink(wtc WorktreeConfig) error {
165165
return nil
166166
}
167167

168+
// WorktreeLinks returns current clone of worktree maps
168169
func (r *Repository) WorktreeLinks() map[string]*WorkTreeLink {
169170
r.lock.RLock()
170171
defer r.lock.RUnlock()
@@ -394,7 +395,7 @@ func (r *Repository) cloneByRef(ctx context.Context, dst, ref, pathspec string,
394395
return hash, nil
395396
}
396397

397-
// returns if repositories mirror loop is running or not
398+
// IsRunning returns if repositories mirror loop is running or not
398399
func (r *Repository) IsRunning() bool {
399400
r.lock.RLock()
400401
defer r.lock.RUnlock()
@@ -498,7 +499,7 @@ func (r *Repository) Mirror(ctx context.Context) error {
498499
}
499500

500501
// RemoveWorktreeLink removes workTree link from the mirror repository.
501-
// it will remove published link as well even if it failed to remove worktree
502+
// it will remove published link as well even (if it failed to remove worktree)
502503
func (r *Repository) RemoveWorktreeLink(link string) error {
503504
r.lock.Lock()
504505
defer r.lock.Unlock()

pkg/mirror/worktree.go

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ type WorkTreeLink struct {
1717
log *slog.Logger
1818
}
1919

20+
// Equals returns if given worktree and its config is equal
21+
// they are considered equal only if link, ref and pathspecs are matching.
22+
// order of pothspecs is ignored
2023
func (wt *WorkTreeLink) Equals(wtc WorktreeConfig) bool {
2124
sortedConfigPaths := slices.Clone(wtc.Pathspecs)
2225
slices.Sort(sortedConfigPaths)

0 commit comments

Comments
 (0)