Commit 1cb6f79f authored by Hubert SABLONNIERE's avatar Hubert SABLONNIERE

rename origin.git.subpath to origin.git.startPath

parent b4ebf593
......@@ -40,7 +40,7 @@ module.exports = async (playbook) => {
}
const componentVersion = await readComponentDesc(files)
componentVersion.files = files.map((file) => assignFileProperties(file, url, branchName, repo.subpath))
componentVersion.files = files.map((file) => assignFileProperties(file, url, branchName, repo.startPath))
return componentVersion
})
.value()
......@@ -161,7 +161,7 @@ function readComponentDesc (files) {
}
async function loadGitFiles (repository, branch, repo) {
const tree = await getGitTree(repository, branch, repo.subpath)
const tree = await getGitTree(repository, branch, repo.startPath)
const entries = await getGitEntries(tree)
const vfiles = entries.map(async (entry) => {
const blob = await entry.getBlob()
......@@ -174,13 +174,13 @@ async function loadGitFiles (repository, branch, repo) {
return Promise.all(vfiles)
}
async function getGitTree (repository, branch, subpath) {
async function getGitTree (repository, branch, startPath) {
const commit = await repository.getBranchCommit(branch)
const tree = await commit.getTree()
if (subpath == null) {
if (startPath == null) {
return tree
}
const subEntry = await tree.entryByPath(subpath)
const subEntry = await tree.entryByPath(startPath)
const subTree = await repository.getTree(subEntry.id())
return subTree
}
......@@ -195,7 +195,7 @@ function getGitEntries (tree, onEntry) {
}
async function loadLocalFiles (repo) {
const basePath = path.join(repo.location, repo.subpath || '.')
const basePath = path.join(repo.location, repo.startPath || '.')
const vfileStream = vfs.src('**/*.*', {
base: basePath,
cwd: basePath,
......@@ -204,7 +204,7 @@ async function loadLocalFiles (repo) {
return streamToArray(vfileStream)
}
function assignFileProperties (file, url, branch, subpath = '/') {
function assignFileProperties (file, url, branch, startPath = '/') {
file.path = file.relative
file.base = process.cwd()
file.cwd = process.cwd()
......@@ -216,7 +216,7 @@ function assignFileProperties (file, url, branch, subpath = '/') {
stem: path.basename(file.path, extname),
extname,
origin: {
git: { url, branch, subpath },
git: { url, branch, startPath },
},
}
return file
......
......@@ -95,18 +95,18 @@ describe('aggregateContent()', () => {
})
})
describe('should read properties from docs-component.yml located at specified subpath', () => {
describe('should read properties from docs-component.yml located at specified startPath', () => {
testAll(async (repo) => {
await repo.initRepo({
name: 'the-component',
title: 'The Component',
version: 'v1.2.3',
nav: ['nav-one.adoc', 'nav-two.adoc'],
subpath: 'docs',
startPath: 'docs',
})
playbook.content.sources.push({
location: repo.location,
subpath: repo.subpath,
startPath: repo.startPath,
})
const corpus = aggregateContent(playbook)
return expect(corpus)
......@@ -296,15 +296,15 @@ describe('aggregateContent()', () => {
'',
'Hey World!',
'',
].join('\n')
].join('\n'),
)
})
})
})
describe('should catalog all files when component is located at a subpath', () => {
describe('should catalog all files when component is located at a startPath', () => {
testAll(async (repo) => {
await repo.initRepo({ name: 'the-component', version: 'v1.2.3', subpath: 'docs' })
await repo.initRepo({ name: 'the-component', version: 'v1.2.3', startPath: 'docs' })
await repo.addFixtureFiles(['should-be-ignored.adoc'])
await repo.addFixtureFiles(
[
......@@ -312,9 +312,9 @@ describe('aggregateContent()', () => {
'modules/ROOT/content/_attributes.adoc',
'modules/ROOT/content/page-one.adoc',
],
'docs'
'docs',
)
playbook.content.sources.push({ location: repo.location, subpath: repo.subpath })
playbook.content.sources.push({ location: repo.location, startPath: repo.startPath })
const corpus = aggregateContent(playbook)
return expect(corpus)
.to.be.fulfilled()
......@@ -543,7 +543,7 @@ describe('aggregateContent()', () => {
// in our test the git url is the same as the repo location we provided
url: repo.location,
branch: 'master',
subpath: '/',
startPath: '/',
},
},
})
......
......@@ -13,8 +13,8 @@ class FixtureRepo {
this.isBare = isBare
}
async initRepo ({ repoName, name, title, version, nav, subpath }) {
this.subpath = subpath
async initRepo ({ repoName, name, title, version, nav, startPath }) {
this.startPath = startPath
this.repoPath = path.join(reposBasePath, repoName || name || 'default-repo')
this.location = this.repoPath
if (this.isRemote) {
......@@ -26,13 +26,13 @@ class FixtureRepo {
this.repository = await git.Repository.init(this.repoPath, 0)
await this.copyAll(['README.adoc'])
await this.commitAll('Init commit', true)
await this.setDocsComponent({ name, title, version, nav, subpath })
await this.setDocsComponent({ name, title, version, nav, startPath })
return this
}
async copyAll (items, subpath = '.') {
async copyAll (items, startPath = '.') {
return Promise.all(
items.map((item) => fs.copy(path.join(fixturesPath, item), path.join(this.repoPath, subpath, item)))
items.map((item) => fs.copy(path.join(fixturesPath, item), path.join(this.repoPath, startPath, item)))
)
}
......@@ -63,8 +63,8 @@ class FixtureRepo {
)
}
async setDocsComponent ({ name, title, version, nav, subpath = '.' }) {
const filepath = path.join(this.repoPath, subpath, 'docs-component.yml')
async setDocsComponent ({ name, title, version, nav, startPath = '.' }) {
const filepath = path.join(this.repoPath, startPath, 'docs-component.yml')
const docsComponentYml = []
if (name) {
docsComponentYml.push(`name: ${name}`)
......@@ -97,8 +97,8 @@ class FixtureRepo {
await this.setDocsComponent({ name, version })
}
async addFixtureFiles (files, subpath) {
await this.copyAll(files, subpath)
async addFixtureFiles (files, startPath) {
await this.copyAll(files, startPath)
await this.commitAll('Add example files')
}
......
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