Skip to content

Commit

Permalink
Merge branch 'master' into fix-config-files-links
Browse files Browse the repository at this point in the history
  • Loading branch information
chan-j-d committed Jul 10, 2023
2 parents 845ba3f + 95f97da commit 99d5400
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
3 changes: 2 additions & 1 deletion docs/ug/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The section below provides explanations for each of the flags.

### `--assets`, `-a`

<div id="section-config">
<div id="section-assets">

**`--assets ASSETS_DIRECTORY`**: Specifies where to place assets for report generation.
* Parameter: `ASSETS_DIRECTORY` The directory containing the assets files. A `favicon.ico` file can be placed here to customize the favicon of the dashboard.
Expand Down Expand Up @@ -56,6 +56,7 @@ The section below provides explanations for each of the flags.

* Cannot be used with `--repos`. The `--repos` flag will take precedence over this flag.
* If both `--repos` and `--config` are not specified, RepoSense looks for config files in the `./config` directory.
* Config files must follow [this](./configFiles.html) format.
</box>
</div>

Expand Down
43 changes: 23 additions & 20 deletions src/main/java/reposense/model/ConfigRunConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package reposense.model;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -40,27 +41,29 @@ public List<RepoConfiguration> getRepoConfigurations()
List<AuthorConfiguration> authorConfigs;
List<GroupConfiguration> groupConfigs;

try {
authorConfigs = new AuthorConfigCsvParser(cliArguments.getAuthorConfigFilePath()).parse();
RepoConfiguration.merge(repoConfigs, authorConfigs);
RepoConfiguration.setHasAuthorConfigFileToRepoConfigs(repoConfigs, true);
} catch (FileNotFoundException fnfe) {
// FileNotFoundException thrown as author-config.csv is not found.
// Ignore exception as the file is optional.
} catch (IOException | InvalidCsvException e) {
// for all IO and invalid csv exceptions, log the error and continue
logger.log(Level.WARNING, e.getMessage(), e);
Path authorConfigFilePath = cliArguments.getAuthorConfigFilePath();
Path groupConfigFilePath = cliArguments.getGroupConfigFilePath();


if (authorConfigFilePath != null && Files.exists(authorConfigFilePath)) {
try {
authorConfigs = new AuthorConfigCsvParser(cliArguments.getAuthorConfigFilePath()).parse();
RepoConfiguration.merge(repoConfigs, authorConfigs);
RepoConfiguration.setHasAuthorConfigFileToRepoConfigs(repoConfigs, true);
} catch (IOException | InvalidCsvException e) {
// for all IO and invalid csv exceptions, log the error and continue
logger.log(Level.WARNING, e.getMessage(), e);
}
}

try {
groupConfigs = new GroupConfigCsvParser(cliArguments.getGroupConfigFilePath()).parse();
RepoConfiguration.setGroupConfigsToRepos(repoConfigs, groupConfigs);
} catch (FileNotFoundException fnfe) {
// FileNotFoundException thrown as groups-config.csv is not found.
// Ignore exception as the file is optional.
} catch (IOException | InvalidCsvException e) {
// for all other IO and invalid csv exceptions, log the error and continue
logger.log(Level.WARNING, e.getMessage(), e);
if (groupConfigFilePath != null && Files.exists(groupConfigFilePath)) {
try {
groupConfigs = new GroupConfigCsvParser(cliArguments.getGroupConfigFilePath()).parse();
RepoConfiguration.setGroupConfigsToRepos(repoConfigs, groupConfigs);
} catch (IOException | InvalidCsvException e) {
// for all IO and invalid csv exceptions, log the error and continue
logger.log(Level.WARNING, e.getMessage(), e);
}
}

return repoConfigs;
Expand Down

0 comments on commit 99d5400

Please sign in to comment.