Skip to content

Commit

Permalink
Merge branch 'refactor-panels-css' of https://github.com/Tejas2805/Re…
Browse files Browse the repository at this point in the history
…poSense into refactor-panels-css

* 'refactor-panels-css' of https://github.com/Tejas2805/RepoSense:
  [reposense#1109] Config.json: include active author and pug file format (reposense#1123)
  [reposense#1004] Make Code Panel consistent with Chart Panel (reposense#1080)
  [reposense#1005, reposense#1010] Code Panel: match font with GitHub and break lines when overflow (reposense#1008)
  [reposense#1076] Author: add a `isIgnoringFile` method (reposense#1085)
  • Loading branch information
Tejas2805 committed Mar 13, 2020
2 parents 14f71b6 + 2456cb2 commit af4f816
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 30 deletions.
12 changes: 6 additions & 6 deletions _reposense/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ignoreGlobList": ["**.adoc", "collate**"],
"formats": ["gradle", "jade", "java", "js", "md", "scss", "yml"],
"formats": ["gradle", "pug", "java", "js", "md", "scss", "yml"],
"ignoreCommitList": ["7b96c563eb2d3612aa5275364333664a18f01491",
"90018e49f129ce7e0abdc8b18e91c9813588c601",
"b8dbc3cf3c7c334665a828cf4236dcb442228c94",
Expand All @@ -9,16 +9,16 @@
"14faede3d27097a74063fd407b210f8a5f7e3de5"],
"authors":
[
{
"githubId": "AdityaA1998",
"displayName": "Aditya",
"authorNames": ["AdityaA1998"]
},
{
"githubId": "eugenepeh",
"displayName": "Eugene",
"authorNames": ["Eugene Peh"]
},
{
"githubId": "jamessspanggg",
"displayName": "James",
"authorNames": ["James Pang"]
},
{
"githubId": "ongspxm",
"displayName": "Metta",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ html
#tab-resize(onmousedown="registerMouseMove()")
.tab-close(v-on:click="deactivateTab")
i.fas.fa-caret-right
.tab-content.tab-padding
.tab-content.panel-padding
.tab-panes
v_authorship#tab-authorship.tab-pane(
v-if="tabType === 'authorship'",
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/static/css/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ $mui-colors: (
'800': #4E342E,
'900': #3E2723,
),
'github': (
'title-background': #FAFBFC,
'border': #E1E4E8,
'authored-code-background': #E6FFED,
),
'grey': (
'50': #FAFAFA,
'100': #F5F5F5,
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/static/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ a {
padding: 2rem 1.5rem;
}

.panel-padding {
padding: 2rem 1.5rem 2rem 2.2rem
}

.warn {
color: mui-color('red');

Expand Down Expand Up @@ -181,7 +185,7 @@ header {
#tabs-wrapper {
$tabs-width: 50%;

background: mui-color('grey', '200');
background: mui-color('white');
flex: 0 0 $tabs-width;
overflow-y: scroll;
position: relative;
Expand All @@ -193,7 +197,7 @@ header {
z-index: z-index('center-divider');

svg {
background-color: mui-color('white');
background-color: mui-color('grey', '300');
color: mui-color('black');
padding: 3rem .25rem;
}
Expand Down
24 changes: 21 additions & 3 deletions frontend/src/static/css/v_authorship.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

/* Authorship */
#tab-authorship {

.file-content {
background-color: mui-color('github', 'title-background');
border: solid mui-color('github', 'border');
border-radius: 0 0 4px 4px;
border-width: 0 1px 1px 1px;
}

.title {
.repoName {
cursor: pointer;
Expand Down Expand Up @@ -95,28 +103,38 @@
.file {
pre {
display: none;
// GitHub's font family and font size
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
font-size: 12px;
}

&.active {
pre {
display: grid;
margin-top: 0;

.hljs {
// overwrite hljs library
display: inherit;
padding: 0;
white-space: pre-wrap;
}
}
}
}

.title {
font-size: 1.25rem;
background-color: mui-color('github', 'title-background');
border: 1px solid mui-color('github', 'border');
border-radius: 4px 4px 0 0;
font-size: medium;
font-weight: bold;
margin-top: 1rem;
padding: .3em .5em;

.path {
cursor: pointer;
overflow-wrap: break-word;
}

.loc {
Expand All @@ -125,7 +143,6 @@

.button {
color: mui-color('grey');
font-size: 1.15rem;
margin-left: .5rem;
text-decoration: none;
}
Expand All @@ -135,7 +152,7 @@
border-left: .25rem solid mui-color('green');

.code {
background-color: mui-color('green', '50');
background-color: mui-color('github', 'authored-code-background');
padding-left: 1rem;
}

Expand All @@ -159,6 +176,7 @@

.line-content {
padding-left: 2rem;
word-break: break-word;
}

&.untouched {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/tabs/authorship.pug
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
title="click to view the blame view of file"
)
i.button.fas.fa-user-edit
pre.hljs
pre.hljs.file-content
template(v-for="segment in file.segments")
v_segment(v-bind:segment="segment", v-bind:path="file.path")

Expand Down
11 changes: 1 addition & 10 deletions src/main/java/reposense/authorship/FileInfoAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.time.ZoneId;
import java.time.ZoneOffset;
Expand Down Expand Up @@ -106,7 +105,7 @@ private static void aggregateBlameAuthorInfo(RepoConfiguration config, FileInfo
commitDateInMs += authorRawOffset - systemRawOffset;
}

if (!fileInfo.isFileLineTracked(lineCount / 5) || isAuthorIgnoringFile(author, filePath)
if (!fileInfo.isFileLineTracked(lineCount / 5) || author.isIgnoringFile(filePath)
|| CommitHash.isInsideCommitList(commitHash, config.getIgnoreCommitList())
|| commitDateInMs < sinceDateInMs || commitDateInMs > untilDateInMs) {
author = Author.UNKNOWN_AUTHOR;
Expand All @@ -122,12 +121,4 @@ private static void aggregateBlameAuthorInfo(RepoConfiguration config, FileInfo
private static String getGitBlameResult(RepoConfiguration config, String filePath) {
return GitBlame.blame(config.getRepoRoot(), filePath);
}

/**
* Returns true if the {@code author} is ignoring the {@code filePath} based on its ignore glob list.
*/
private static boolean isAuthorIgnoringFile(Author author, Path filePath) {
PathMatcher ignoreGlobMatcher = author.getIgnoreGlobMatcher();
return ignoreGlobMatcher.matches(filePath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void aggregateAnnotationAuthorInfo(FileInfo fileInfo, Map<String,
if (newAuthor.equals(Author.UNKNOWN_AUTHOR)) {
//end of an author tag should belong to this author too.
lineInfo.setAuthor(currentAuthor);
} else if (newAuthor.getIgnoreGlobMatcher().matches(filePath)) {
} else if (newAuthor.isIgnoringFile(filePath)) {
newAuthor = Author.UNKNOWN_AUTHOR;
}

Expand Down
12 changes: 8 additions & 4 deletions src/main/java/reposense/model/Author.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package reposense.model;

import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -130,10 +131,6 @@ public void setIgnoreGlobList(List<String> ignoreGlobList) {
updateIgnoreGlobMatcher();
}

public PathMatcher getIgnoreGlobMatcher() {
return ignoreGlobMatcher;
}

/**
* Validates and adds a list of ignore glob into the {@code Author} class instance variable without duplicates
* and updates the ignore glob matcher.
Expand All @@ -148,6 +145,13 @@ public void importIgnoreGlobList(List<String> ignoreGlobList) {
updateIgnoreGlobMatcher();
}

/**
* Returns true if this author is ignoring the {@code filePath} based on its ignore glob matcher.
*/
public boolean isIgnoringFile(Path filePath) {
return ignoreGlobMatcher.matches(filePath);
}

@Override
public boolean equals(Object other) {
// short circuit if same object
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/reposense/model/AuthorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void setIgnoreGlobList_validGlobRegex_success() {
Assert.assertEquals(2, author.getIgnoreGlobList().size());
Assert.assertTrue(author.getIgnoreGlobList().containsAll(Arrays.asList(ignoreGlobs)));
Arrays.stream(testPaths).forEach(value ->
Assert.assertTrue(author.getIgnoreGlobMatcher().matches(Paths.get(value))));
Assert.assertTrue(author.isIgnoringFile(Paths.get(value))));
}

@Test(expected = IllegalArgumentException.class)
Expand Down Expand Up @@ -84,7 +84,7 @@ public void appendIgnoreGlobList_validGlobRegex_success() {
Assert.assertEquals(4, author.getIgnoreGlobList().size());
Assert.assertTrue(author.getIgnoreGlobList().containsAll(ignoreGlobList));
Arrays.stream(testPaths).forEach(value ->
Assert.assertTrue(author.getIgnoreGlobMatcher().matches(Paths.get(value))));
Assert.assertTrue(author.isIgnoringFile(Paths.get(value))));
}

@Test(expected = IllegalArgumentException.class)
Expand Down

0 comments on commit af4f816

Please sign in to comment.