Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove PR related unused methods #18

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions pkg/mirror/repo_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,6 @@ func (rp *RepoPool) ChangedFiles(ctx context.Context, remote, hash string) ([]st
return repo.ChangedFiles(ctx, hash)
}

// ChangedFilesBetweenRefs is wrapper around repositories ChangedFilesBetweenRefs method
// git diff --name-only HEAD...refs/pull/13179/head
// git diff --name-only --merge-base HEAD refs/pull/13179/head
func (rp *RepoPool) ChangedFilesBetweenRefs(ctx context.Context, remote, ref1, ref2 string) ([]string, error) {
repo, err := rp.Repository(remote)
if err != nil {
return nil, err
}
return repo.ChangedFilesBetweenRefs(ctx, ref1, ref2)
}

// CommitsBetweenRefs is wrapper around repositories CommitsBetweenRefs method
// git rev-list ^HEAD refs/pull/13179/head
func (rp *RepoPool) CommitsBetweenRefs(ctx context.Context, remote, ref1, ref2 string) ([]string, error) {
repo, err := rp.Repository(remote)
if err != nil {
return nil, err
}
return repo.CommitsBetweenRefs(ctx, ref1, ref2)
}

// ObjectExists is wrapper around repositories ObjectExists method
func (rp *RepoPool) ObjectExists(ctx context.Context, remote, obj string) error {
repo, err := rp.Repository(remote)
Expand Down
46 changes: 0 additions & 46 deletions pkg/mirror/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,52 +220,6 @@ func (r *Repository) ChangedFiles(ctx context.Context, hash string) ([]string, e
return strings.Split(msg, "\n"), nil
}

// ChangedFilesBetweenRefs returns path of the changed files between ref1 and ref2,
// using the merge base of the two commits for the "before" side.
// git diff --name-only HEAD...refs/pull/13179/head
// git diff --name-only --merge-base HEAD refs/pull/13179/head
func (r *Repository) ChangedFilesBetweenRefs(ctx context.Context, ref1, ref2 string) ([]string, error) {
r.lock.RLock()
defer r.lock.RUnlock()

if err := r.ObjectExists(ctx, ref1); err != nil {
return nil, err
}
if err := r.ObjectExists(ctx, ref2); err != nil {
return nil, err
}

// merge-base finds the best common ancestor(s) between two commits to use in a three-way merge.
args := []string{"diff", `--name-only`, `--merge-base`, ref1, ref2}
msg, err := runGitCommand(ctx, r.log, r.envs, r.dir, args...)
if err != nil {
return nil, err
}
return strings.Split(msg, "\n"), nil
}

// ChangedFiles returns list of all the commits which are reachable from ref2, but not from ref1".
// list is in reverse order ie old commit -> new commit
// git rev-list ^HEAD refs/pull/13179/head
func (r *Repository) CommitsBetweenRefs(ctx context.Context, ref1, ref2 string) ([]string, error) {
r.lock.RLock()
defer r.lock.RUnlock()

if err := r.ObjectExists(ctx, ref1); err != nil {
return nil, err
}
if err := r.ObjectExists(ctx, ref2); err != nil {
return nil, err
}

args := []string{"rev-list", `--reverse`, "^" + ref1, ref2}
msg, err := runGitCommand(ctx, r.log, r.envs, r.dir, args...)
if err != nil {
return nil, err
}
return strings.Split(msg, "\n"), nil
}

// ObjectExists returns error is given object is not valid or if it doesn't exists
func (r *Repository) ObjectExists(ctx context.Context, obj string) error {
r.lock.RLock()
Expand Down