Skip to content

Commit

Permalink
Update Yaml file format
Browse files Browse the repository at this point in the history
  • Loading branch information
georgetayqy committed Apr 8, 2024
1 parent 7c94fea commit 6ee3249
Show file tree
Hide file tree
Showing 17 changed files with 524 additions and 103 deletions.
55 changes: 39 additions & 16 deletions config/report-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
title: RepoSense Report
group-details:
- repo: https://github.com/user/repo/tree/fake-branch
groups:
- group-name: code
globs:
- "**.java"
- group-name: tests
globs:
- "src/test**"
- group-name: docs
globs:
- "docs**"
- "**.adoc"
- "**.md"
repos:
- repo: https://github.com/user/repo
authorNames:
- johnDoe
- John Doe
- my home PC
- repo: https://github.com/user/repo/tree/fake-branch
author-emails:
- [email protected]
- [email protected]
- [email protected]
author-git-host-id: johnDoe
author-display-name: John Doe
author-git-author-name: my home PC
branches:
- branch: main
blurb: very long blurb
- branch: master
blurb: very very long blurb
- repo: https://github.com/user/repo2
authorNames:
- author1
- author One
- my author PC
branches:
- branch: main
blurb: very very very long blurb
file-formats:
- override:java
- md
- fxml
ignore-glob-list:
- "docs**"
ignore-standalone-config: true
ignore-commits-list:
- 2fb6b9b2dd9fa40bf0f9815da2cb0ae8731436c7
- c5a6dc774e22099cd9ddeb0faff1e75f9cf4f151
- cd7f610e0becbdf331d5231887d8010a689f87c7
- 768015345e70f06add2a8b7d1f901dc07bf70582
ignore-authors-list:
- author1
- author2
is-shallow-cloning: true
is-find-previous-authors: false
5 changes: 1 addition & 4 deletions src/main/java/reposense/model/CliArguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ public Path getReportConfigFilePath() {
return reportConfigFilePath;
}

public ReportConfiguration getReportYamlConfiguration() {
return reportConfiguration;
}

public ReportConfiguration getReportConfiguration() {
return reportConfiguration;
}
Expand Down Expand Up @@ -201,6 +197,7 @@ public boolean equals(Object other) {
&& this.isFreshClonePerformed == otherCliArguments.isFreshClonePerformed
&& Objects.equals(this.locations, otherCliArguments.locations)
&& this.isViewModeOnly == otherCliArguments.isViewModeOnly
&& Objects.equals(this.reportConfiguration, otherCliArguments.reportConfiguration)
&& Objects.equals(this.reportDirectoryPath, otherCliArguments.reportDirectoryPath)
&& Objects.equals(this.repoConfigFilePath, otherCliArguments.repoConfigFilePath)
&& Objects.equals(this.authorConfigFilePath, otherCliArguments.authorConfigFilePath)
Expand Down
98 changes: 90 additions & 8 deletions src/main/java/reposense/model/reportconfig/ReportBranchData.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,101 @@
package reposense.model.reportconfig;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Represents a single entry of a branch in the YAML config file.
*/
public class ReportBranchData {
public static final String DEFAULT_BRANCH = "main";
public static final String DEFAULT_BLURB = "very long blurb";
public static final List<String> DEFAULT_FILE_FORMATS = List.of(
"override:java", "md", "fxml"
);
public static final List<String> DEFAULT_IGNORE_GLOB_LIST = List.of(
"docs**"
);
public static final List<String> DEFAULT_IGNORE_COMMITS_LIST = List.of(
"2fb6b9b2dd9fa40bf0f9815da2cb0ae8731436c7",
"c5a6dc774e22099cd9ddeb0faff1e75f9cf4f151",
"cd7f610e0becbdf331d5231887d8010a689f87c7",
"768015345e70f06add2a8b7d1f901dc07bf70582"
);
public static final List<String> DEFAULT_IGNORE_AUTHORS_LIST = List.of(
"author1",
"author2"
);
public static final boolean DEFAULT_IS_FIND_PREVIOUS_AUTHOR = false;
public static final boolean DEFAULT_IS_SHALLOW_CLONING = true;
public static final boolean DEFAULT_IS_IGNORE_STANDALONE_CONFIG = true;

public static final ReportBranchData DEFAULT_INSTANCE = new ReportBranchData();

static {
DEFAULT_INSTANCE.branch = ReportBranchData.DEFAULT_BRANCH;
DEFAULT_INSTANCE.fileFormats = ReportBranchData.DEFAULT_FILE_FORMATS;
DEFAULT_INSTANCE.ignoreGlobList = ReportBranchData.DEFAULT_IGNORE_GLOB_LIST;
DEFAULT_INSTANCE.ignoreCommitList = ReportBranchData.DEFAULT_IGNORE_COMMITS_LIST;
DEFAULT_INSTANCE.ignoreAuthorList = ReportBranchData.DEFAULT_IGNORE_AUTHORS_LIST;
DEFAULT_INSTANCE.isFindPreviousAuthor = ReportBranchData.DEFAULT_IS_FIND_PREVIOUS_AUTHOR;
DEFAULT_INSTANCE.isShallowCloning = ReportBranchData.DEFAULT_IS_SHALLOW_CLONING;
DEFAULT_INSTANCE.isIgnoreStandaloneConfig = ReportBranchData.DEFAULT_IS_IGNORE_STANDALONE_CONFIG;
}

@JsonProperty("branch")
private String branch;

@JsonProperty("blurb")
private String blurb;
@JsonProperty("file-formats")
private List<String> fileFormats;

@JsonProperty("ignore-glob-list")
private List<String> ignoreGlobList;

@JsonProperty("ignore-standalone-config")
private Boolean isIgnoreStandaloneConfig;

@JsonProperty("ignore-commits-list")
private List<String> ignoreCommitList;

@JsonProperty("ignore-authors-list")
private List<String> ignoreAuthorList;

@JsonProperty("is-shallow-cloning")
private Boolean isShallowCloning;

@JsonProperty("is-find-previous-authors")
private Boolean isFindPreviousAuthor;

public String getBranch() {
return branch == null ? DEFAULT_BRANCH : branch;
}

public String getBlurb() {
return blurb == null ? DEFAULT_BLURB : blurb;
public List<String> getFileFormats() {
return fileFormats == null ? DEFAULT_FILE_FORMATS : fileFormats;
}

public List<String> getIgnoreGlobList() {
return ignoreGlobList == null ? DEFAULT_IGNORE_GLOB_LIST : fileFormats;
}

public boolean getIsIgnoreStandaloneConfig() {
return isIgnoreStandaloneConfig == null ? DEFAULT_IS_IGNORE_STANDALONE_CONFIG : isIgnoreStandaloneConfig;
}

public List<String> getIgnoreCommitList() {
return ignoreCommitList == null ? DEFAULT_IGNORE_COMMITS_LIST : ignoreCommitList;
}

public List<String> getIgnoreAuthorList() {
return ignoreAuthorList == null ? DEFAULT_IGNORE_AUTHORS_LIST : ignoreAuthorList;
}

public boolean getIsShallowCloning() {
return isShallowCloning == null ? DEFAULT_IS_SHALLOW_CLONING : isShallowCloning;
}

public boolean getIsFindPreviousAuthor() {
return isFindPreviousAuthor == null ? DEFAULT_IS_FIND_PREVIOUS_AUTHOR : isFindPreviousAuthor;
}

@Override
Expand All @@ -29,9 +105,15 @@ public boolean equals(Object obj) {
}

if (obj instanceof ReportBranchData) {
ReportBranchData reportBranchData = (ReportBranchData) obj;
return reportBranchData.getBranch().equals(this.getBranch())
&& reportBranchData.getBlurb().equals(this.getBlurb());
ReportBranchData rbd = (ReportBranchData) obj;
return this.getBranch().equals(rbd.getBranch())
&& this.getFileFormats().equals(rbd.getFileFormats())
&& this.getIgnoreGlobList().equals(rbd.getIgnoreGlobList())
&& this.getIsIgnoreStandaloneConfig() == rbd.getIsIgnoreStandaloneConfig()
&& this.getIgnoreCommitList().equals(rbd.getIgnoreCommitList())
&& this.getIgnoreAuthorList().equals(rbd.getIgnoreAuthorList())
&& this.getIsShallowCloning() == rbd.getIsShallowCloning()
&& this.getIsFindPreviousAuthor() == rbd.getIsFindPreviousAuthor();
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,31 @@
*/
public class ReportConfiguration {
public static final String DEFAULT_TITLE = "RepoSense Report";
public static final List<ReportGroupDetails> DEFAULT_REPORT_GROUP_DETAILS = new ArrayList<>();
public static final List<ReportRepoConfiguration> DEFAULT_REPORT_REPO_CONFIGS = new ArrayList<>();

static {
DEFAULT_REPORT_REPO_CONFIGS.add(
ReportRepoConfiguration.DEFAULT_INSTANCE
);
DEFAULT_REPORT_REPO_CONFIGS.add(ReportRepoConfiguration.DEFAULT_INSTANCE);
DEFAULT_REPORT_GROUP_DETAILS.add(ReportGroupDetails.DEFAULT_INSTANCE);
}

@JsonProperty("title")
private String title;

@JsonProperty("group-details")
private List<ReportGroupDetails> groupDetails;

@JsonProperty("repos")
private List<ReportRepoConfiguration> reportRepoConfigurations;

public String getTitle() {
return title == null ? DEFAULT_TITLE : title;
}

public List<ReportGroupDetails> getGroupDetails() {
return groupDetails == null ? DEFAULT_REPORT_GROUP_DETAILS : groupDetails;
}

public List<ReportRepoConfiguration> getReportRepoConfigurations() {
return reportRepoConfigurations == null ? DEFAULT_REPORT_REPO_CONFIGS : reportRepoConfigurations;
}
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/reposense/model/reportconfig/ReportGroupDetails.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package reposense.model.reportconfig;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Contains information about the group contained in a particular repo.
*/
public class ReportGroupDetails {
public static final String DEFAULT_REPO = "https://github.com/user/repo/tree/fake-branch";
public static final List<ReportGroupNameAndGlobs> DEFAULT_NAMES_AND_GLOBS =
ReportGroupNameAndGlobs.DEFAULT_INSTANCES;
public static final ReportGroupDetails DEFAULT_INSTANCE = new ReportGroupDetails();

static {
DEFAULT_INSTANCE.repo = DEFAULT_REPO;
DEFAULT_INSTANCE.reportGroupNameAndGlobsList = ReportGroupNameAndGlobs.DEFAULT_INSTANCES;
}

@JsonProperty("repo")
private String repo;

@JsonProperty("groups")
private List<ReportGroupNameAndGlobs> reportGroupNameAndGlobsList;

public String getRepo() {
return repo == null ? DEFAULT_REPO : repo;
}

public List<ReportGroupNameAndGlobs> getReportGroupNameAndGlobsList() {
return reportGroupNameAndGlobsList == null ? DEFAULT_NAMES_AND_GLOBS : reportGroupNameAndGlobsList;
}

@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}

if (obj instanceof ReportGroupDetails) {
ReportGroupDetails rgd = (ReportGroupDetails) obj;
return this.getRepo().equals(rgd.getRepo())
&& this.getReportGroupNameAndGlobsList().equals(rgd.getReportGroupNameAndGlobsList());
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package reposense.model.reportconfig;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Contains details about each report group and the corresponding globs.
*/
public class ReportGroupNameAndGlobs {
public static final String DEFAULT_GROUP_NAME = "code";
public static final List<String> DEFAULT_GLOBS = List.of(
"**.java"
);
public static final List<ReportGroupNameAndGlobs> DEFAULT_INSTANCES = new ArrayList<>();

static {
ReportGroupNameAndGlobs rg1 = new ReportGroupNameAndGlobs();
rg1.groupName = "code";
rg1.globs = List.of("**.java");

ReportGroupNameAndGlobs rg2 = new ReportGroupNameAndGlobs();
rg2.groupName = "tests";
rg2.globs = List.of("src/test**");

ReportGroupNameAndGlobs rg3 = new ReportGroupNameAndGlobs();
rg3.groupName = "docs";
rg3.globs = List.of("docs**", "**.adoc", "**.md");

DEFAULT_INSTANCES.add(rg1);
DEFAULT_INSTANCES.add(rg2);
DEFAULT_INSTANCES.add(rg3);
}

@JsonProperty("group-name")
private String groupName;

@JsonProperty("globs")
private List<String> globs;

public String getGroupName() {
return groupName == null ? DEFAULT_GROUP_NAME : groupName;
}

public List<String> getGlobs() {
return globs == null ? DEFAULT_GLOBS : globs;
}

@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}

if (obj instanceof ReportGroupNameAndGlobs) {
ReportGroupNameAndGlobs rgnag = (ReportGroupNameAndGlobs) obj;
return rgnag.getGroupName().equals(this.getGroupName())
&& rgnag.getGlobs().equals(this.getGlobs());
}

return false;
}

@Override
public String toString() {
return "RGNAG { group-name: " + this.groupName + ", globs: " + this.globs + "}";
}
}
Loading

0 comments on commit 6ee3249

Please sign in to comment.