Skip to content

Commit

Permalink
Merge pull request #33 from aMarcireau/import
Browse files Browse the repository at this point in the history
Import
  • Loading branch information
Alexandre Marcireau authored Dec 4, 2017
2 parents d23df9e + 1faa1f2 commit 645fffb
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 26 deletions.
16 changes: 8 additions & 8 deletions release.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ if (!semverMatch) {
process.exit(1);
}
const version = {
major: semverMatch[1],
minor: semverMatch[2],
patch: semverMatch[3],
major: parseInt(semverMatch[1]),
minor: parseInt(semverMatch[2]),
patch: parseInt(semverMatch[3]),
identifier: semverMatch[4] ? semverMatch[4] : null,
};

Expand Down Expand Up @@ -167,9 +167,9 @@ usernameInterface.question('username: ', username => {
const releaseSemverMatch = semver.exec(release.tag_name);
if (releaseSemverMatch) {
const releaseVersion = {
major: releaseSemverMatch[1],
minor: releaseSemverMatch[2],
patch: releaseSemverMatch[3],
major: parseInt(releaseSemverMatch[1]),
minor: parseInt(releaseSemverMatch[2]),
patch: parseInt(releaseSemverMatch[3]),
identifier: releaseSemverMatch[4] ? releaseSemverMatch[4] : null,
};
if (release.draft) {
Expand Down Expand Up @@ -206,7 +206,7 @@ usernameInterface.question('username: ', username => {
|| areEqual(version, releaseVersion)
) {
console.log(`${release.tag_name} (${release.id}) is greater than or identical to the current version: skipping automatic operations`);
} else if (release.assets.length > 0) {
} else {
releasesAndVersionsToPurge.push({
release: release,
version: releaseVersion,
Expand Down Expand Up @@ -262,7 +262,7 @@ usernameInterface.question('username: ', username => {
previousMajorVersion && areEqual(previousMajorVersion, releaseAndVersion.version)
|| previousMinorVersion && areEqual(previousMinorVersion, releaseAndVersion.version)
) {
console.log(`${releaseAndVersion.release.tag_name} (${releaseAndVersion.release.id}) was not purged (previous ${areEqual(previousMajorVersion, releaseAndVersion.version) ? 'major' : 'minor'})`);
console.log(`${releaseAndVersion.release.tag_name} (${releaseAndVersion.release.id}) was not purged (previous ${previousMajorVersion && areEqual(previousMajorVersion, releaseAndVersion.version) ? 'major' : 'minor'})`);
continue;
}
for (const asset of releaseAndVersion.release.assets) {
Expand Down
2 changes: 1 addition & 1 deletion source/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Origami",
"version": "0.7.0",
"version": "0.7.1",
"main": "main.js",
"private": true,
"devDependencies": {
Expand Down
36 changes: 20 additions & 16 deletions source/reducers/publications.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,14 @@ export default function publications(state = new Map(), action, appState) {
}
case RESOLVE_IMPORT_DOIS: {
const newState = new Map(state);
const foundDois = new Set();
for (const rawDoi of action.dois) {
const match = doiPattern.exec(rawDoi);
if (match) {
const doi = match[1].toLowerCase();
if (foundDois.has(doi)) {
continue;
}
if (state.has(doi)) {
if (state.get(doi).status === PUBLICATION_STATUS_DEFAULT) {
const newState = new Map(state);
Expand All @@ -439,23 +443,23 @@ export default function publications(state = new Map(), action, appState) {
updated: action.timestamp,
});
}
} else {
newState.set(doi, {
status: PUBLICATION_STATUS_UNVALIDATED,
title: null,
authors: null,
journal: null,
date: null,
citers: [],
updated: null,
selected: false,
validating: false,
bibtex: null,
x: null,
y: null,
locked: false,
});
continue;
}
newState.set(doi, {
status: PUBLICATION_STATUS_UNVALIDATED,
title: null,
authors: null,
journal: null,
date: null,
citers: [],
updated: null,
selected: false,
validating: false,
bibtex: null,
x: null,
y: null,
locked: false,
});
}
}
return newState;
Expand Down
5 changes: 5 additions & 0 deletions source/reducers/scholar.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,15 @@ export default function scholar(
...state,
pages[...state.pages],
};
const foundDois = new Set();
for (const rawDoi of action.dois) {
const match = doiPattern.exec(rawDoi);
if (match) {
const doi = match[1].toLowerCase();
if (foundDois.has(doi)) {
continue;
}
foundDois.add(doi);
if (appState.publications.has(doi) && appState.publications.get(doi).status !== PUBLICATION_STATUS_DEFAULT) {
continue;
}
Expand Down
19 changes: 18 additions & 1 deletion source/reducers/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,25 @@ export default function warnings(state = {list: [], hash: 0}, action, appState)
list: [...state.list],
hash: state.hash + 1,
};
const foundDois = new Set();
const warnedDois = new Set();
for (const rawDoi of action.dois) {
if (!doiPattern.test(rawDoi)) {
const match = doiPattern.exec(rawDoi);
if (match) {
const doi = match[1].toLowerCase();
if (foundDois.has(doi)) {
if (!warnedDois.has(doi)) {
warnedDois.add(doi);
newState.list.push({
title: 'There are identical DOIs in the list',
subtitle: `'${doi}' appears at least twice`,
level: 'warning',
});
}
} else {
foundDois.add(doi);
}
} else {
newState.list.push({
title: 'Importing one of the DOIs failed',
subtitle: `'${rawDoi}' does not match the expected format`,
Expand Down

0 comments on commit 645fffb

Please sign in to comment.