Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Accidental Publication of Unintended USFM Books and keep manifest file in master branch unaltered after release #201

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions src/utils/dcsApis.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,24 +452,28 @@ export async function updateManifest({
}

if ( ! RESOURCES_WITH_NO_BOOK_FILES.includes( resourceId ) ) {
for ( let bookId of books ) {
for (let bookId of books) {
// If the book is not in the manifest, add it
if ( !manifest.projects.find( ( item ) => item.identifier === bookId ) ) {
const project = getProject( {
bookId, resourceId, languageId,
} )

// If the project has a path, add it to the manifest
if ( project.path ) {
const index = manifest.projects.findLastIndex( ( item ) => item.sort > project.sort )
manifest.projects.splice( index, 0, project )
}
}
}

// If this is a first release, remove any projects that are not in the books array
if ( firstRelease ) {
manifest.projects = manifest.projects.filter( (item) => books.includes(item.identifier))
}
}

// Update the manifest in the release branch
const updatedRes = await updateManifestInBranch({
server, organization, languageId, resourceId, tokenid, branch:releaseBranchName, manifest, sha,
})
Expand Down Expand Up @@ -598,7 +602,7 @@ async function deleteAllBookFilesNotInManifest( {
const resourceTree = trees.tree

for ( const file of resourceTree ) {
if ( file.path.endsWith('.tsv') ) {
if ( file.path.endsWith('.tsv') || file.path.endsWith('.usfm') ) {
if ( manifest.projects.some(( elem ) => {
let path = elem.path

Expand Down Expand Up @@ -731,7 +735,7 @@ export async function createRelease({
})
}

if ('tn' === resourceId) {
if (!RESOURCES_WITH_NO_BOOK_FILES.includes( resourceId )) {
// Clean up any old files such as when migrated from TSV9 to TSV7 delete old files.
await deleteAllBookFilesNotInManifest({
releaseBranchName,
Expand Down Expand Up @@ -793,16 +797,6 @@ export async function createRelease({
val.message = `Created release ${nextVersion} of ${languageId}_${resourceId}`
val.version = nextVersion

// Update manifest in master after release.
if (releaseBranchName !== 'master') {
const updatedRes = await updateManifestInBranch({
server, organization, languageId, resourceId, tokenid, branch:'master', manifest,
})

if ( ! updatedRes.ok ) {
console.warn(`failed to update master manifest.yaml ${updatedRes.status}`)
}
}
} else if ( res.status === 404 ) {
val.status = false
val.message = `Repo does not exist (404): ${languageId}_${resourceId}`
Expand Down