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

[#2170] Add Blurbs for Repos #2191

Merged
merged 30 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f6a4c2c
Implement Blurb Feature
asdfghjkxd Apr 15, 2024
b906f6e
Implement Frontend Tests For Blurbs
asdfghjkxd Apr 15, 2024
f143dc5
Update frontend tests
asdfghjkxd Apr 15, 2024
f0d38cb
Merge branch 'master' of https://github.com/reposense/RepoSense into …
sopa301 Apr 30, 2024
aaefdd5
Merge branch 'implement-blurbs-feature' of https://github.com/asdfghj…
sopa301 Apr 30, 2024
71c4c31
Remove unintended changes
sopa301 Apr 30, 2024
ededbf9
Undo unintended changes
sopa301 Apr 30, 2024
28d50b8
Undo unintended changes
sopa301 Apr 30, 2024
970e2ec
Fix style
sopa301 Apr 30, 2024
e323d51
Fix style
sopa301 Apr 30, 2024
812a098
Fix style
sopa301 Apr 30, 2024
b2967c2
Undo title changes
sopa301 May 2, 2024
44fce64
Add removed spacing line in title
sopa301 May 2, 2024
21f2b69
Implement more test cases
asdfghjkxd May 6, 2024
405655e
Merge branch 'master' into implement-blurbs-feature
ckcherry23 May 11, 2024
a79db9a
Restyle blurb
sopa301 May 12, 2024
3e6ec16
Update tests
sopa301 May 12, 2024
c5cbd37
Add test cases for BlurbMarkdownParser
asdfghjkxd May 12, 2024
eab097b
Fix environmental errors
asdfghjkxd May 12, 2024
b6b8fb8
Update docs
sopa301 May 12, 2024
9a8626b
Merge branch 'implement-blurbs-feature' of https://github.com/asdfghj…
sopa301 May 12, 2024
dcb2536
Update example link
sopa301 May 12, 2024
64b71d9
Remove extraneous line
asdfghjkxd May 12, 2024
6e0c654
Merge branch 'implement-blurbs-feature' of https://github.com/asdfghj…
asdfghjkxd May 12, 2024
0e76fe4
Merge branch 'master' into implement-blurbs-feature
ckcherry23 May 12, 2024
a96eed5
Edit tests to use markdown syntax
sopa301 May 12, 2024
3f979da
Refactor constants and remove dependencies
asdfghjkxd May 12, 2024
bcf7010
Refactor BlurbMap
asdfghjkxd May 12, 2024
3791288
Update blurbs
asdfghjkxd May 12, 2024
a37f1bf
Add HTML text in blurbs
asdfghjkxd May 12, 2024
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dependencies {
implementation group: 'org.apache.ant', name: 'ant', version: '1.10.12'
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.9.0'
implementation group: 'org.fusesource.jansi', name: 'jansi', version: '2.4.0'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.17.0'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.17.0'
ckcherry23 marked this conversation as resolved.
Show resolved Hide resolved

testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion
Expand Down
2 changes: 2 additions & 0 deletions config/blurbs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://github.com/reposense/testrepo-Alpha/tree/master
Master branch of testrepo-Alpha
5 changes: 5 additions & 0 deletions frontend/cypress/config/blurbs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://github.com/reposense/RepoSense/tree/cypress
ckcherry23 marked this conversation as resolved.
Show resolved Hide resolved
first blurb
<!--repo-->------------------------------------
https://gitlab.com/reposense/testrepo-gitlab/-/tree/main
unseen blurb
12 changes: 12 additions & 0 deletions frontend/cypress/tests/chartView/chartView_blurbs.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe('blurbs', () => {
it('shows blurbs', () => {
cy.get('.markdown.blurb')
.first()
.should('contain', 'first blurb');
});

it('has the correct number of valid blurbs', () => {
ckcherry23 marked this conversation as resolved.
Show resolved Hide resolved
cy.get('.markdown.blurb')
.should('have.length', 1);
});
});
2 changes: 2 additions & 0 deletions frontend/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const app = defineComponent({
reportGenerationTime,
errorMessages,
names,
blurbMap,
} = summary;
this.creationDate = creationDate;
this.reportGenerationTime = reportGenerationTime;
Expand All @@ -134,6 +135,7 @@ const app = defineComponent({
this.getUsers();
this.renderTabHash();
this.userUpdated = true;
this.$store.commit('setBlurbMap', blurbMap);
} catch (error) {
window.alert(error);
} finally {
Expand Down
30 changes: 30 additions & 0 deletions frontend/src/components/c-markdown-chunk.vue
sopa301 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template lang="pug">
.markdown(v-html="parsedHtml", v-if="markdownText != ''")
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import MarkdownIt from 'markdown-it';

export default defineComponent({
props: {
markdownText: {
type: String,
required: true,
},
},
computed: {
parsedHtml() {
const md = new MarkdownIt({ html: true });
return md.render(this.markdownText);
},
},
});
</script>

<style lang="scss" scoped>
.markdown {
overflow-x: auto;
padding: 0 1.5rem;
}
</style>
37 changes: 35 additions & 2 deletions frontend/src/components/c-summary-charts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@
)
font-awesome-icon.icon-button(icon="clipboard")
span.tooltip-text(v-bind:ref="`summary-charts-${i}-copy-iframe`") Click to copy iframe link for group

.tooltip.summary-chart__title--percentile(
v-if="sortGroupSelection.includes('totalCommits')"
v-if="sortGroupSelection.includes('totalCommits')"
) {{ getPercentile(i) }} %&nbsp
span.tooltip-text.right-aligned {{ getPercentileExplanation(i) }}
.summary-charts__title--tags(
Expand All @@ -158,6 +157,14 @@
)
font-awesome-icon(icon="tags")
span &nbsp;{{ tag }}

.blurbWrapper(
v-if="filterGroupSelection === 'groupByRepos'",
)
c-markdown-chunk.blurb(
v-bind:markdown-text="getBlurb(repo[0])"
)

.summary-charts__fileType--breakdown(v-if="filterBreakdown")
template(v-if="filterGroupSelection !== 'groupByNone'")
.summary-charts__fileType--breakdown__legend(
Expand Down Expand Up @@ -337,6 +344,7 @@ import brokenLinkDisabler from '../mixin/brokenLinkMixin';
import tooltipPositioner from '../mixin/dynamicTooltipMixin';
import cRamp from './c-ramp.vue';
import cStackedBarChart from './c-stacked-bar-chart.vue';
import cMarkdownChunk from './c-markdown-chunk.vue';
import { Bar, Repo, User } from '../types/types';
import { FilterGroupSelection, FilterTimeFrame, SortGroupSelection } from '../types/summary';
import { StoreState, ZoomInfo } from '../types/vuex.d';
Expand All @@ -347,6 +355,7 @@ export default defineComponent({
components: {
cRamp,
cStackedBarChart,
cMarkdownChunk,
},
mixins: [brokenLinkDisabler, tooltipPositioner],
props: {
Expand Down Expand Up @@ -984,10 +993,34 @@ export default defineComponent({
return [...new Set(repo.flatMap((r) => r.commits).flatMap((c) => c.commitResults).flatMap((r) => r.tags))]
.filter(Boolean) as Array<string>;
},

getBlurb(repo: User): string {
const link = this.getRepoLink(repo);
if (!link) {
return '';
}
const blurb: string | undefined = this.$store.state.blurbMap[link];
if (!blurb) {
return '';
}
return blurb;
},
},
});
</script>

<style lang="scss" scoped>
@import '../styles/tags.scss';
@import '../styles/_colors.scss';

.blurbWrapper {
padding-bottom: 5px;

.blurb {
background-color: #fafafa;
overflow-y: hidden;
// This is needed because the parent summary-wrapper center aligns everything
text-align: initial;
}
}
</style>
4 changes: 4 additions & 0 deletions frontend/src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default createStore<StoreState>({
loadingOverlayCount: 0,
loadingOverlayMessage: '',
isTabActive: true,
blurbMap: {},
} as StoreState,
mutations: {
updateTabZoomInfo(state: StoreState, info: ZoomInfo) {
Expand Down Expand Up @@ -82,6 +83,9 @@ export default createStore<StoreState>({
file.wasCodeLoaded = file.wasCodeLoaded || file.active;
});
},
setBlurbMap(state: StoreState, blurbMap: { [key: string]: string }) {
state.blurbMap = blurbMap;
},
},
actions: {
// Actions are called with dispatch
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/vuex.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface StoreState {
loadingOverlayCount: number;
loadingOverlayMessage: string;
isTabActive: boolean;
blurbMap: { [key: string]: string };
}

declare module '@vue/runtime-core' {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface Api {
reportGenerationTime: string;
errorMessages: { [key: string]: ErrorMessage };
names: string[];
blurbMap: { [key: string]: string };
} | null>;
loadCommits: (repoName: string) => Promise<User[]>;
loadAuthorship: (repoName: string) => Promise<AuthorshipSchema>;
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/types/zod/summary-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const summarySchema = z.object({
isUntilDateProvided: z.boolean(),
isAuthorshipAnalyzed: z.boolean().default(false), // for backwards compatability
supportedDomainUrlMap: supportedDomainUrlMapSchema,
blurbs: z.object({
urlBlurbMap: z.record(z.string(), z.string()),
}),
});

// Export typescript types
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,14 @@ window.api = {
window.REPOS[repoName] = repo;
names.push(repoName);
});

const blurbMap: { [key: string]: string } = data.blurbs.urlBlurbMap;
return {
creationDate: reportGeneratedTime,
reportGenerationTime,
errorMessages,
names,
blurbMap,
};
},

Expand Down
10 changes: 9 additions & 1 deletion src/main/java/reposense/RepoSense.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@

import net.sourceforge.argparse4j.helper.HelpScreenException;
import reposense.git.GitConfig;
import reposense.model.BlurbMap;
import reposense.model.CliArguments;
import reposense.model.RepoConfiguration;
import reposense.model.ReportConfiguration;
import reposense.model.RunConfigurationDecider;
import reposense.parser.ArgsParser;
import reposense.parser.exceptions.InvalidCsvException;
import reposense.parser.exceptions.InvalidHeaderException;
import reposense.parser.exceptions.InvalidMarkdownException;
import reposense.parser.exceptions.ParseException;
import reposense.report.ReportGenerator;
import reposense.system.LogsManager;
Expand All @@ -43,6 +45,7 @@ public static void main(String[] args) {
CliArguments cliArguments = ArgsParser.parse(args);
List<RepoConfiguration> configs = null;
ReportConfiguration reportConfig = new ReportConfiguration();
BlurbMap blurbMap = new BlurbMap();

if (cliArguments.isViewModeOnly()) {
ReportServer.startServer(SERVER_PORT_NUMBER, cliArguments.getReportDirectoryPath().toAbsolutePath());
Expand All @@ -51,6 +54,7 @@ public static void main(String[] args) {

configs = RunConfigurationDecider.getRunConfiguration(cliArguments).getRepoConfigurations();
reportConfig = cliArguments.getReportConfiguration();
blurbMap = cliArguments.getBlurbMap();

RepoConfiguration.setFormatsToRepoConfigs(configs, cliArguments.getFormats());
RepoConfiguration.setDatesToRepoConfigs(configs, cliArguments.getSinceDate(), cliArguments.getUntilDate());
Expand Down Expand Up @@ -80,7 +84,9 @@ public static void main(String[] args) {
cliArguments.isSinceDateProvided(), cliArguments.isUntilDateProvided(),
cliArguments.getNumCloningThreads(), cliArguments.getNumAnalysisThreads(),
TimeUtil::getElapsedTime, cliArguments.getZoneId(), cliArguments.isFreshClonePerformed(),
cliArguments.isAuthorshipAnalyzed(), cliArguments.getOriginalityThreshold());
cliArguments.isAuthorshipAnalyzed(), cliArguments.getOriginalityThreshold(),
blurbMap
);

FileUtil.zipFoldersAndFiles(reportFoldersAndFiles, cliArguments.getOutputFilePath().toAbsolutePath(),
".json");
Expand All @@ -97,6 +103,8 @@ public static void main(String[] args) {
logger.log(Level.WARNING, e.getMessage(), e);
} catch (HelpScreenException e) {
// help message was printed by the ArgumentParser; it is safe to exit.
} catch (InvalidMarkdownException ex) {
logger.log(Level.SEVERE, ex.getMessage(), ex);
}

LogsManager.moveLogFileToOutputFolder();
Expand Down
67 changes: 67 additions & 0 deletions src/main/java/reposense/model/BlurbMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package reposense.model;

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Represents the mapping between the repo URL to the associated blurb.
*/
public class BlurbMap {
@JsonProperty("urlBlurbMap")
private final Map<String, String> urlBlurbMap;

public BlurbMap() {
this.urlBlurbMap = new HashMap<>();
}

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

if (obj instanceof BlurbMap) {
BlurbMap bm = (BlurbMap) obj;
return bm.urlBlurbMap.equals(this.urlBlurbMap);
}

return false;
}

/**
* Builder class to help in the building of a {@code BlurbMap}.
*/
public static final class Builder {
ckcherry23 marked this conversation as resolved.
Show resolved Hide resolved
private BlurbMap blurbMap;

public Builder() {
blurbMap = new BlurbMap();
}


/**
* Adds a key-value record into the {@code BlurbMap}.
*
* @param key Key value.
* @param value Blurb value.
* @return This {@code Builder}.
*/
public Builder withRecord(String key, String value) {
blurbMap.urlBlurbMap.put(key, value);
return this;
}

/**
* Returns a built instance of {@code BlurbMap}.
*
* @return Built {@code BlurbMap}.
*/
public BlurbMap build() {
BlurbMap built = this.blurbMap;
this.blurbMap = new BlurbMap();
return built;
}
}
}
16 changes: 16 additions & 0 deletions src/main/java/reposense/model/CliArguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class CliArguments {
private Path groupConfigFilePath;
private Path reportConfigFilePath;
private ReportConfiguration reportConfiguration;
private BlurbMap blurbMap;

/**
* Constructs a {@code CliArguments} object without any parameters.
Expand Down Expand Up @@ -161,6 +162,10 @@ public ReportConfiguration getReportConfiguration() {
return reportConfiguration;
}

public BlurbMap getBlurbMap() {
return blurbMap;
}

public boolean isViewModeOnly() {
return isViewModeOnly;
}
Expand Down Expand Up @@ -211,6 +216,7 @@ public boolean equals(Object other) {
&& Objects.equals(this.authorConfigFilePath, otherCliArguments.authorConfigFilePath)
&& Objects.equals(this.groupConfigFilePath, otherCliArguments.groupConfigFilePath)
&& Objects.equals(this.reportConfigFilePath, otherCliArguments.reportConfigFilePath)
&& Objects.equals(this.blurbMap, otherCliArguments.blurbMap)
&& this.isAuthorshipAnalyzed == otherCliArguments.isAuthorshipAnalyzed
&& Objects.equals(this.originalityThreshold, otherCliArguments.originalityThreshold);
}
Expand Down Expand Up @@ -487,6 +493,16 @@ public Builder originalityThreshold(double originalityThreshold) {
return this;
}

/**
* Adds the {@code blurbMap} to CliArguments.
*
* @param blurbMap The blurb map.
*/
public Builder blurbMap(BlurbMap blurbMap) {
this.cliArguments.blurbMap = blurbMap;
return this;
}

/**
* Builds CliArguments.
*
Expand Down
Loading
Loading