Commit 91d2e0fe authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Commit: implement hpd_display_parent_id and _ids

This was missing, and could turn out to be useful, even though
analysis shows that's not the case for #385.

The new tests look to be trivial, because display ids
are just the ids for commits of Git repositories. But
the point is to check the APIs are internally consistent
and avoid mistakes in refactorings.

There is a test in HgGitRepository that makes sure that
the Mercurial conversion for display is correct.

--HG--
branch : heptapod-stable
parent 0a568e3d5b87
......@@ -274,10 +274,22 @@ def parent_ids
@parent_ids ||= @repository.commit(id).parent_ids
end
def hpd_display_parent_ids
# not yet loaded is probably just nil, but [] would be correct
# as well since parent_ids uses ||=
return parent_ids unless parent_ids
parent_ids.map { |id| @repository.commit_id_to_display_id(id) }
end
def parent_id
parent_ids.first
end
def hpd_display_parent_id
hpd_display_parent_ids.first
end
def parent_hgid
parent_hgids.first
end
......
......@@ -58,6 +58,7 @@
it { expect(@commit.different_committer?).to be_truthy }
it { expect(@commit.parents).to eq(@gitlab_parents) }
it { expect(@commit.parent_id).to eq(@parents.first.oid) }
it { expect(@commit.hpd_display_parent_id).to eq(@parents.first.oid) }
it { expect(@commit.no_commit_message).to eq("No commit message") }
after do
......@@ -86,6 +87,7 @@
it { expect(commit.committer_name).to eq(committer.name) }
it { expect(commit.committer_email).to eq(committer.email) }
it { expect(commit.parent_ids).to eq(gitaly_commit.parent_ids) }
it { expect(commit.hpd_display_parent_ids).to eq(gitaly_commit.parent_ids) }
context 'non-UTC dates' do
let(:seconds) { Time.now.to_i }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment