Skip to content

Commit

Permalink
feat: [#123] git-queue does not require to set 40-char for commit hashes
Browse files Browse the repository at this point in the history
Bug external project: nautilus-cyberneering/library-consumer#22
Internal issue: #123

The bug was temporarily fixed by setting git config to:

git config --global core.abbrev 7

We do not need it anymore becuase SimpleGit has force commit hash length
to the maximum (40 chararters). So we only use full hashes.
  • Loading branch information
josecelano authored and da2ce7 committed Apr 13, 2022
1 parent 9d933a4 commit ea85e15
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 336 deletions.
9 changes: 0 additions & 9 deletions __tests__/unit/commit-hash.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {CommitHash, nullCommitHash} from '../../src/commit-hash'
import {ShortCommitHash} from '../../src/short-commit-hash'

describe('CommitHash', () => {
it('should contain the hash of a git commit', () => {
Expand Down Expand Up @@ -55,12 +54,4 @@ describe('CommitHash', () => {
expect(commit.toString()).toBe('ad5cea6308f69d7955d8de5f0da19f675d5ba75f')
expect(commit.getHash()).toBe('ad5cea6308f69d7955d8de5f0da19f675d5ba75f')
})

it('could be converted to a short hash', () => {
const commit = new CommitHash('ad5cea6308f69d7955d8de5f0da19f675d5ba75f')

expect(commit.getShortHash().equalsTo(new ShortCommitHash('ad5cea6'))).toBe(
true
)
})
})
33 changes: 0 additions & 33 deletions __tests__/unit/committed-message-log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {CommitInfo} from '../../src/commit-info'
import {CommittedMessage} from '../../src/committed-message'
import {CommittedMessageLog} from '../../src/committed-message-log'
import {DefaultLogFields} from 'simple-git'
import {ShortCommitHash} from '../../src/short-commit-hash'

function dummyNewJobCommitSubjectText(): string {
return '📝🈺: queue-name: job.ref.f1a69d48a01cc130a64aeac5eaf762e4ba685de7'
Expand Down Expand Up @@ -142,24 +141,6 @@ describe('CommittedMessageLog', () => {
).toBe(true)
})

it('should find a message by a full 7-character commit hash', async () => {
const commit = dummySimpleGitCommitWithHash(
'f1a69d48a01cc130a64aeac5eaf762e4ba685de7'
)

const committedMessageLog = CommittedMessageLog.fromGitLogCommits([commit])

const expectedMessage = CommittedMessage.fromCommitInfo(
CommitInfo.fromDefaultLogFields(commit)
)

expect(
committedMessageLog
.findByShortCommitHash(new ShortCommitHash('f1a69d4'))
.equalsTo(expectedMessage)
).toBe(true)
})

it('should return a null message if it can not find a message by its commit hash', async () => {
const commit = dummySimpleGitCommitWithHash(
'f1a69d48a01cc130a64aeac5eaf762e4ba685de7'
Expand All @@ -175,18 +156,4 @@ describe('CommittedMessageLog', () => {
.isNull()
).toBe(true)
})

it('should return a null message if it can not find a message by its short commit hash', async () => {
const commit = dummySimpleGitCommitWithHash(
'f1a69d48a01cc130a64aeac5eaf762e4ba685de7'
)

const committedMessageLog = CommittedMessageLog.fromGitLogCommits([commit])

expect(
committedMessageLog
.findByShortCommitHash(new ShortCommitHash('2ab1cce'))
.isNull()
).toBe(true)
})
})
47 changes: 0 additions & 47 deletions __tests__/unit/short-commit-hash.test.ts

This file was deleted.

Loading

0 comments on commit ea85e15

Please sign in to comment.