Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into bibtestFiles
Browse files Browse the repository at this point in the history
* upstream/main:
  Bump org.apache.lucene:lucene-core from 9.9.1 to 9.9.2 (#10860)
  Bump org.junit.jupiter:junit-jupiter from 5.10.1 to 5.10.2 (#10863)
  Bump org.apache.lucene:lucene-highlighter from 9.9.1 to 9.9.2 (#10861)
  Bump org.tinylog:tinylog-api from 2.6.2 to 2.7.0 (#10862)
  Bump org.apache.lucene:lucene-queryparser from 9.9.1 to 9.9.2 (#10859)
  Bump gradle/wrapper-validation-action from 1 to 2 (#10858)
  Bump codecov/codecov-action from 3 to 4 (#10857)
  Bump peter-evans/create-pull-request from 5 to 6 (#10856)
  Update Gradle Wrapper from 8.5 to 8.6. (#10854)
  Enable auto merge of gradle wrapper update
  Jump to entry from cli (#10578)
  Fix closing of JabRef in case of issues with index writer (#10840)
  Update deployment-arm64.yml
  Fix secrents presence chcek
  • Loading branch information
Siedlerchr committed Feb 6, 2024
2 parents b7e1bb4 + 7001cb3 commit 6b4a7c0
Show file tree
Hide file tree
Showing 39 changed files with 488 additions and 214 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
(
startsWith(github.event.pull_request.title, '[Bot] ') ||
startsWith(github.event.pull_request.title, 'Bump ') ||
startsWith(github.event.pull_request.title, 'New Crowdin updates')
startsWith(github.event.pull_request.title, 'New Crowdin updates') ||
startsWith(github.event.pull_request.title, 'Update Gradle Wrapper from')
)
)
steps:
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/deployment-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ jobs:
displayName: macOS (Arm64)
suffix: '_arm64'
runs-on: ${{ matrix.os }}
outputs:
major: ${{ steps.gitversion.outputs.Major }}
minor: ${{ steps.gitversion.outputs.Minor }}
branchname: ${{ steps.gitversion.outputs.branchName }}
name: Create installer and portable version for ${{ matrix.displayName }}
steps:
- name: Check secrets presence
id: checksecrets
shell: bash
run: |
[ -n "$BUILDJABREFPRIVATEKEY" ] || exit 1
if [ "$BUILDJABREFPRIVATEKEY" == "" ]; then
echo "secretspresent=NO" >> $GITHUB_OUTPUT
else
echo "secretspresent=YES" >> $GITHUB_OUTPUT
fi
env:
BUILDJABREFPRIVATEKEY: ${{ secrets.buildJabRefPrivateKey }}
BUILDJABREFPRIVATEKEY: ${{ secrets.buildJabRefPrivateKey }}
- name: Fetch all history for all tags and branches
uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/refresh-csl-subtrees.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
git add -f src/main/resources/csl-styles
git add -f src/main/resources/csl-locales
git diff-index --quiet HEAD || git commit -m 'Update CSL styles'
- uses: peter-evans/create-pull-request@v5
- uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_TOKEN_UPDATE_GRADLE_WRAPPER }}
branch: refresh-csl
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/refresh-journal-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: |
git add -f buildres/abbrv.jabref.org
git diff-index --quiet HEAD || git commit -m 'Update journal abbreviation lists'
- uses: peter-evans/create-pull-request@v5
- uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_TOKEN_UPDATE_GRADLE_WRAPPER }}
branch: update-journal-lists
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ jobs:
CI: "true"
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
DBMS: "postgresql"
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
if: (github.ref == 'refs/heads/main') && (steps.checksecrets.outputs.secretspresent == 'YES')
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -306,7 +306,7 @@ jobs:
- uses: actions/checkout@v4
with:
show-progress: 'false'
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/wrapper-validation-action@v2
# This ensures that no git merge conflict markers (<<<, ...) are contained
merge_conflict_job:
name: Find merge conflicts
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added a fetcher for [ISIDORE](https://isidore.science/), simply paste in the link into the text field or the last 6 digits in the link that identify that paper. [#10423](https://github.com/JabRef/jabref/issues/10423)
- When importing entries form the "Citation relations" tab, the field [cites](https://docs.jabref.org/advanced/entryeditor/entrylinks) is now filled according to the relationship between the entries. [#10572](https://github.com/JabRef/jabref/pull/10752)
- We added a new group icon column to the main table showing the icons of the entry's groups. [#10801](https://github.com/JabRef/jabref/pull/10801)
- We added ability to jump to an entry in the command line using `-j CITATIONKEY`. [koppor#540](https://github.com/koppor/jabref/issues/540)
- We added a new boolean to the style files for Openoffice/Libreoffice integration to switch between ZERO_WIDTH_SPACE (default) and no space. [#10843](https://github.com/JabRef/jabref/pull/10843)

### Changed
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ dependencies {
exclude group: 'org.junit.jupiter'
}

implementation 'org.apache.lucene:lucene-core:9.9.1'
implementation 'org.apache.lucene:lucene-queryparser:9.9.1'
implementation 'org.apache.lucene:lucene-core:9.9.2'
implementation 'org.apache.lucene:lucene-queryparser:9.9.2'
implementation 'org.apache.lucene:lucene-queries:9.9.1'
implementation 'org.apache.lucene:lucene-analysis-common:9.9.1'
implementation 'org.apache.lucene:lucene-highlighter:9.9.1'
implementation 'org.apache.lucene:lucene-highlighter:9.9.2'

implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.10.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
Expand Down Expand Up @@ -188,7 +188,7 @@ dependencies {
implementation 'com.konghq:unirest-java:3.14.5'

implementation 'org.slf4j:slf4j-api:2.0.11'
implementation "org.tinylog:tinylog-api:2.6.2"
implementation "org.tinylog:tinylog-api:2.7.0"
implementation "org.tinylog:slf4j-tinylog:2.6.2"
implementation "org.tinylog:tinylog-impl:2.6.2"

Expand Down Expand Up @@ -241,7 +241,7 @@ dependencies {
implementation 'org.jspecify:jspecify:0.3.0'

testImplementation 'io.github.classgraph:classgraph:4.8.165'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testImplementation 'org.junit.platform:junit-platform-launcher:1.10.1'

testImplementation 'org.mockito:mockito-core:5.10.0'
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
60 changes: 36 additions & 24 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jabref.gui.externalfiles.AutoSetFileLinksUtil;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.logic.JabRefException;
import org.jabref.logic.UiCommand;
import org.jabref.logic.bibtex.FieldPreferences;
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
import org.jabref.logic.exporter.AtomicFileWriter;
Expand Down Expand Up @@ -64,28 +65,31 @@
import org.slf4j.LoggerFactory;

public class ArgumentProcessor {

private static final Logger LOGGER = LoggerFactory.getLogger(ArgumentProcessor.class);
private final JabRefCLI cli;

// Written once by processArguments()
private List<ParserResult> parserResults = List.of();
public enum Mode { INITIAL_START, REMOTE_START }

private final JabRefCLI cli;

private final Mode startupMode;

private final PreferencesService preferencesService;
private final FileUpdateMonitor fileUpdateMonitor;
private final BibEntryTypesManager entryTypesManager;
private boolean noGUINeeded;

private boolean guiNeeded;
private final List<UiCommand> uiCommands = new ArrayList<>();

/**
* First call the constructor, then call {@link #processArguments()}.
* Afterward, you can access the {@link #getParserResults()} and other getters.
* Afterward, you can access the {@link #getUiCommands()}.
*/
public ArgumentProcessor(String[] args,
Mode startupMode,
PreferencesService preferencesService,
FileUpdateMonitor fileUpdateMonitor,
BibEntryTypesManager entryTypesManager) throws org.apache.commons.cli.ParseException {
BibEntryTypesManager entryTypesManager)
throws org.apache.commons.cli.ParseException {
this.cli = new JabRefCLI(args);
this.startupMode = startupMode;
this.preferencesService = preferencesService;
Expand Down Expand Up @@ -121,6 +125,7 @@ private Optional<ParserResult> importBibtexToOpenBase(String argument, ImportFor
}

private Optional<ParserResult> importFile(String argument) {
LOGGER.debug("Importing file {}", argument);
String[] data = argument.split(",");

String address = data[0];
Expand Down Expand Up @@ -185,22 +190,21 @@ private Optional<ParserResult> importFile(Path file, String importFormat) {
}
}

public List<ParserResult> getParserResults() {
return parserResults;
}

public void processArguments() {
uiCommands.clear();

if ((startupMode == Mode.INITIAL_START) && cli.isShowVersion()) {
cli.displayVersion();
}

if ((startupMode == Mode.INITIAL_START) && cli.isHelp()) {
JabRefCLI.printUsage(preferencesService);
noGUINeeded = true;
this.parserResults = Collections.emptyList();
guiNeeded = false;
return;
}

guiNeeded = true;

// Check if we should reset all preferences to default values:
if (cli.isPreferencesReset()) {
resetPreferences(cli.getPreferencesReset());
Expand All @@ -211,7 +215,6 @@ public void processArguments() {
importPreferences();
}

// List to put imported/loaded database(s) in.
List<ParserResult> loaded = importAndOpenFiles();

if (!cli.isBlank() && cli.isFetcherEngine()) {
Expand All @@ -221,7 +224,6 @@ public void processArguments() {
if (cli.isExportMatches()) {
if (!loaded.isEmpty()) {
if (!exportMatches(loaded)) {
this.parserResults = Collections.emptyList();
return;
}
} else {
Expand Down Expand Up @@ -277,7 +279,17 @@ public void processArguments() {
doAuxImport(loaded);
}

this.parserResults = loaded;
if (cli.isBlank()) {
uiCommands.add(new UiCommand.BlankWorkspace());
}

if (!cli.isBlank() && cli.isJumpToKey()) {
uiCommands.add(new UiCommand.JumpToEntryKey(cli.getJumpToKey()));
}

if (!cli.isBlank() && !loaded.isEmpty()) {
uiCommands.add(new UiCommand.OpenDatabases(loaded));
}
}

private void writeMetadataToPdf(List<ParserResult> loaded,
Expand Down Expand Up @@ -460,7 +472,7 @@ private boolean exportMatches(List<ParserResult> loaded) {
default -> {
System.err.println(Localization.lang("Output file missing").concat(". \n \t ")
.concat(Localization.lang("Usage")).concat(": ") + JabRefCLI.getExportMatchesSyntax());
noGUINeeded = true;
guiNeeded = false;
return false;
}
}
Expand Down Expand Up @@ -510,6 +522,9 @@ private void doAuxImport(List<ParserResult> loaded) {
}
}

/**
* @return List of opened files (could be .bib, but also other formats). May also contain error results.
*/
private List<ParserResult> importAndOpenFiles() {
List<ParserResult> loaded = new ArrayList<>();
List<String> toImport = new ArrayList<>();
Expand All @@ -527,6 +542,7 @@ private List<ParserResult> importAndOpenFiles() {
Path.of(aLeftOver),
preferencesService.getImportFormatPreferences(),
fileUpdateMonitor);
// In contrast to org.jabref.gui.LibraryTab.onDatabaseLoadingSucceed, we do not execute OpenDatabaseAction.performPostOpenActions(result, dialogService);
} catch (IOException ex) {
pr = ParserResult.fromError(ex);
LOGGER.error("Error opening file '{}'", aLeftOver, ex);
Expand Down Expand Up @@ -773,15 +789,11 @@ private Optional<ParserResult> fetch(String fetchCommand) {
}
}

public boolean isBlank() {
return cli.isBlank();
}

public boolean shouldShutDown() {
return cli.isDisableGui() || cli.isShowVersion() || noGUINeeded;
return cli.isDisableGui() || cli.isShowVersion() || !guiNeeded;
}

public enum Mode {
INITIAL_START, REMOTE_START
public List<UiCommand> getUiCommands() {
return uiCommands;
}
}
18 changes: 17 additions & 1 deletion src/main/java/org/jabref/cli/JabRefCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ public String getWriteMetadatatoPdf() {
cl.hasOption("embeddBibfileInPdf") ? cl.getOptionValue("embeddBibfileInPdf") : null;
}

public String getJumpToKey() {
return cl.getOptionValue("jumpToKey");
}

public boolean isJumpToKey() {
return cl.hasOption("jumpToKey");
}

private static Options getOptions() {
Options options = new Options();

Expand Down Expand Up @@ -275,7 +283,7 @@ private static Options getOptions() {
options.addOption(Option
.builder()
.longOpt("embeddBibfileInPdf")
.desc("%s: '%s'".formatted(Localization.lang("Embed BibTeXEntry in PDF."), "-w pathToMyOwnPaper.pdf"))
.desc("%s: '%s'".formatted(Localization.lang("Embed BibTeX as attached file in PDF."), "-w pathToMyOwnPaper.pdf"))
.hasArg()
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
.build());
Expand All @@ -288,6 +296,14 @@ private static Options getOptions() {
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
.build());

options.addOption(Option
.builder("j")
.longOpt("jumpToKey")
.desc("%s: '%s'".formatted(Localization.lang("Jump to the entry of the given citation key."), "-j key"))
.hasArg()
.argName("CITATIONKEY")
.build());

return options;
}

Expand Down
Loading

0 comments on commit 6b4a7c0

Please sign in to comment.