Skip to content

Commit

Permalink
Merge pull request #18 from utilitywarehouse/as-rm-pr
Browse files Browse the repository at this point in the history
remove PR related unused methods
  • Loading branch information
asiyani committed Jul 3, 2024
2 parents df9edf4 + 99dc89b commit f4d4ee6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 67 deletions.
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

0 comments on commit f4d4ee6

Please sign in to comment.