diff --git a/CHANGELOG.md b/CHANGELOG.md index a14f44262..c006fb58b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,15 @@ All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## Unreleased [patch] + +### Fixed + +_Full changeset and discussions: [#1045](https://github.com/OpenTermsArchive/engine/pull/1045)._ + +> Development of this release was supported by the [French Ministry for Foreign Affairs](https://www.diplomatie.gouv.fr/fr/politique-etrangere-de-la-france/diplomatie-numerique/) through its ministerial [State Startups incubator](https://beta.gouv.fr/startups/open-terms-archive.html) under the aegis of the Ambassador for Digital Affairs. + +- Fix support of special character in service names ## 0.34.1 - 2023-12-19 diff --git a/src/archivist/index.test.js b/src/archivist/index.test.js index 5ed26c5ab..1d54a15f9 100644 --- a/src/archivist/index.test.js +++ b/src/archivist/index.test.js @@ -35,7 +35,7 @@ async function resetGitRepositories() { describe('Archivist', function () { this.timeout(10000); - const SERVICE_A_ID = 'service_A'; + const SERVICE_A_ID = 'service·A'; const SERVICE_A_TYPE = 'Terms of Service'; const SERVICE_A_EXPECTED_SNAPSHOT_FILE_PATH = `${SNAPSHOTS_PATH}/${SERVICE_A_ID}/${SERVICE_A_TYPE}.html`; const SERVICE_A_EXPECTED_VERSION_FILE_PATH = `${VERSIONS_PATH}/${SERVICE_A_ID}/${SERVICE_A_TYPE}.md`; @@ -49,7 +49,7 @@ describe('Archivist', function () { let serviceBSnapshotExpectedContent; let serviceBVersionExpectedContent; - const services = [ 'service_A', 'Service B!' ]; + const services = [ 'service·A', 'Service B!' ]; before(async () => { gitVersion = new Git({ @@ -61,8 +61,8 @@ describe('Archivist', function () { }); await gitVersion.initialize(); - serviceASnapshotExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/service_A_terms_snapshot.html'), { encoding: 'utf8' }); - serviceAVersionExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/service_A_terms.md'), { encoding: 'utf8' }); + serviceASnapshotExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/service·A_terms_snapshot.html'), { encoding: 'utf8' }); + serviceAVersionExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/service·A_terms.md'), { encoding: 'utf8' }); serviceBSnapshotExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/terms.pdf')); serviceBVersionExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/termsFromPDF.md'), { encoding: 'utf8' }); }); @@ -166,7 +166,7 @@ describe('Archivist', function () { app.services[SERVICE_A_ID].getTerms({ type: SERVICE_A_TYPE }).sourceDocuments[0].contentSelectors = 'h1'; - await app.track({ services: [ 'service_A', 'Service B!' ], extractOnly: true }); + await app.track({ services: [ 'service·A', 'Service B!' ], extractOnly: true }); const [reExtractedVersionCommit] = await gitVersion.log({ file: SERVICE_A_EXPECTED_VERSION_FILE_PATH }); @@ -282,7 +282,7 @@ describe('Archivist', function () { let snapshot; before(async () => { - terms = app.services.service_A.getTerms({ type: SERVICE_A_TYPE }); + terms = app.services.service·A.getTerms({ type: SERVICE_A_TYPE }); terms.fetchDate = FETCH_DATE; terms.sourceDocuments.forEach(async sourceDocument => { sourceDocument.content = serviceASnapshotExpectedContent; @@ -364,7 +364,7 @@ describe('Archivist', function () { let version; before(async () => { - terms = app.services.service_A.getTerms({ type: SERVICE_A_TYPE }); + terms = app.services.service·A.getTerms({ type: SERVICE_A_TYPE }); terms.fetchDate = FETCH_DATE; terms.sourceDocuments.forEach(async sourceDocument => { sourceDocument.content = serviceASnapshotExpectedContent; diff --git a/src/archivist/recorder/repositories/git/git.js b/src/archivist/recorder/repositories/git/git.js index eaf82a2ff..3e4069324 100644 --- a/src/archivist/recorder/repositories/git/git.js +++ b/src/archivist/recorder/repositories/git/git.js @@ -26,7 +26,8 @@ export default class Git { .addConfig('core.autocrlf', false) .addConfig('push.default', 'current') .addConfig('user.name', this.author.name) - .addConfig('user.email', this.author.email); + .addConfig('user.email', this.author.email) + .addConfig('core.quotePath', false); // disable Git's encoding of special characters in pathnames. For example, `service·A` will be encoded as `service\302\267A` without this setting, leading to issues. See https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath } async add(filePath) { diff --git a/src/archivist/services/index.test.js b/src/archivist/services/index.test.js index c1dc97983..2d2a5d4c7 100644 --- a/src/archivist/services/index.test.js +++ b/src/archivist/services/index.test.js @@ -97,8 +97,8 @@ describe('Services', () => { result = await services.load(); }); - describe('Service A', async () => { - await validateServiceWithoutHistory('service_A', expectedServices.service_A); + describe('Service·A', async () => { + await validateServiceWithoutHistory('service·A', expectedServices.service·A); }); describe('Service B', async () => { @@ -127,11 +127,11 @@ describe('Services', () => { context('when specifying services to load', async () => { before(async () => { - result = await services.load([ 'service_A', 'Service B!' ]); + result = await services.load([ 'service·A', 'Service B!' ]); }); it('loads only the given services', async () => { - expect(result).to.have.all.keys('service_A', 'Service B!'); + expect(result).to.have.all.keys('service·A', 'Service B!'); }); }); }); @@ -266,8 +266,8 @@ describe('Services', () => { result = await services.loadWithHistory(); }); - describe('Service A', async () => { - await validateServiceWithHistory('service_A', expectedServices.service_A); + describe('Service·A', async () => { + await validateServiceWithHistory('service·A', expectedServices.service·A); }); describe('Service B', async () => { @@ -296,11 +296,11 @@ describe('Services', () => { context('when specifying services to load', async () => { before(async () => { - result = await services.loadWithHistory([ 'service_A', 'Service B!' ]); + result = await services.loadWithHistory([ 'service·A', 'Service B!' ]); }); it('loads only the given services', async () => { - expect(result).to.have.all.keys('service_A', 'Service B!'); + expect(result).to.have.all.keys('service·A', 'Service B!'); }); }); }); diff --git a/test/fixtures/services.js b/test/fixtures/services.js index b85a03e01..86f1bf492 100644 --- a/test/fixtures/services.js +++ b/test/fixtures/services.js @@ -1,10 +1,10 @@ -import serviceA from './service_A.js'; import serviceB from './service_B.js'; import serviceWithDeclarationHistory from './service_with_declaration_history.js'; import serviceWithFiltersHistory from './service_with_filters_history.js'; import serviceWithHistory from './service_with_history.js'; import serviceWithMultipleSourceDocumentsTerms from './service_with_multiple_source_documents_terms.js'; import serviceWithoutHistory from './service_without_history.js'; +import serviceA from './service·A.js'; const services = { service_with_history: serviceWithHistory, @@ -12,7 +12,7 @@ const services = { service_with_filters_history: serviceWithFiltersHistory, service_with_declaration_history: serviceWithDeclarationHistory, service_with_multiple_source_documents_terms: serviceWithMultipleSourceDocumentsTerms, - service_A: serviceA, + service·A: serviceA, 'Service B!': serviceB, }; diff --git a/test/fixtures/service_A.js "b/test/fixtures/service\302\267A.js" similarity index 92% rename from test/fixtures/service_A.js rename to "test/fixtures/service\302\267A.js" index afc4c4ecf..8fccb1204 100644 --- a/test/fixtures/service_A.js +++ "b/test/fixtures/service\302\267A.js" @@ -3,8 +3,8 @@ import SourceDocument from '../../src/archivist/services/sourceDocument.js'; import Terms from '../../src/archivist/services/terms.js'; const service = new Service({ - id: 'service_A', - name: 'Service A', + id: 'service·A', + name: 'Service·A', }); service.addTerms(new Terms({ diff --git a/test/fixtures/service_A_terms.md "b/test/fixtures/service\302\267A_terms.md" similarity index 100% rename from test/fixtures/service_A_terms.md rename to "test/fixtures/service\302\267A_terms.md" diff --git a/test/fixtures/service_A_terms_snapshot.html "b/test/fixtures/service\302\267A_terms_snapshot.html" similarity index 100% rename from test/fixtures/service_A_terms_snapshot.html rename to "test/fixtures/service\302\267A_terms_snapshot.html" diff --git a/test/services/service_A.json "b/test/services/service\302\267A.json" similarity index 84% rename from test/services/service_A.json rename to "test/services/service\302\267A.json" index 898635b60..102b2a21e 100644 --- a/test/services/service_A.json +++ "b/test/services/service\302\267A.json" @@ -1,5 +1,5 @@ { - "name": "Service A", + "name": "Service·A", "documents": { "Terms of Service": { "fetch": "https://www.servicea.example/tos",