Skip to content

Commit

Permalink
refactor: misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita_Stepochkin authored and Nikita_Stepochkin committed May 17, 2019
1 parent 079ab45 commit 98d78ed
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class FileSystemSourceCodeStorage(
baseFileRecordRepository.deleteAllByRepoAndBranch(repo, branchName)
val filePatterns = repositoryDataManager.findFileNameRegexps(repo)
forEachFileInDirectory(tempDir) { foundedFile ->
val fileName = File(tempDir).toPath().relativize(foundedFile.toPath()).toString()
val fileName = File(tempDir).toPath().relativize(foundedFile.toPath()).toString().replace("\\", "/")
if (nameMatchesRegex(fileName, filePatterns)) {
foundedFile.copyTo(File("$pathToBases/$fileName"))
baseFileRecordRepository.save(
Expand All @@ -170,14 +170,13 @@ class FileSystemSourceCodeStorage(
solutionFileRecordRepository.deleteAllByPullRequest(pullRequest)
val filePatterns = repositoryDataManager.findFileNameRegexps(pullRequest.repo)
forEachFileInDirectory(tempDir) { foundedFile ->
val fileName = File(tempDir).toPath().relativize(foundedFile.toPath()).toString()
val fileName = File(tempDir).toPath().relativize(foundedFile.toPath()).toString().replace("\\", "/")
if (nameMatchesRegex(fileName, filePatterns)) {
foundedFile.copyTo(File("$pathToSolutions/$fileName"))
solutionFileRecordRepository.save(
SolutionFileRecord(
pullRequest = pullRequest,
fileName = fileName,
countOfLines = Files.lines(foundedFile.toPath()).count().toInt()
fileName = fileName
)
)
logger.info {
Expand Down Expand Up @@ -224,6 +223,7 @@ class FileSystemSourceCodeStorage(
substringAfterLast(".")

private fun nameMatchesRegex(fileName: String, filePatterns: Collection<String>): Boolean {
if (filePatterns.isEmpty()) return true
filePatterns.forEach {
if (it.toRegex().matches(fileName)) return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class SourceFileQueriesTest {

private val base1 = BaseFileRecord(repo = repo, fileName = fileName1, branch = branch1)
private val base2 = BaseFileRecord(repo = repo, fileName = fileName2, branch = branch2)
private val sol1 = SolutionFileRecord(pullRequest = pullRequest1, fileName = fileName1, countOfLines = 10)
private val sol2 = SolutionFileRecord(pullRequest = pullRequest2, fileName = fileName2, countOfLines = 20)
private val sol1 = SolutionFileRecord(pullRequest = pullRequest1, fileName = fileName1)
private val sol2 = SolutionFileRecord(pullRequest = pullRequest2, fileName = fileName2)

private val solutionFileRecordRepository = mock<SolutionFileRecordRepository> {
on { findAllByRepo(repo) } doReturn listOf(sol1, sol2)
Expand Down
Binary file added frontend/public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8"/>
<link href="%PUBLIC_URL%/favicon.ico" rel="shortcut icon"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta content="#000000" name="theme-color"/>
<!--
Expand Down
18 changes: 1 addition & 17 deletions frontend/src/components/NewRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,6 @@ export class NewRepo extends React.Component {
</div>
</div>
{this.selectLanguages()}
{/*<div className="form-group">*/}
{/*<legend className="col-form-label">Default analysis mode</legend>*/}
{/*<div className="btn-group btn-group-toggle" data-toggle="buttons" onChange={this.handleChange}>*/}
{/*<label className="btn btn-light" htmlFor="mode1" onClick={this.handlePlatformChange}>*/}
{/*<input type="radio" id="mode1" name="analysisMode" value="LINK"*/}
{/*checked={this.state.analysisMode === "LINK"}/>Link</label>*/}
{/*<label className="btn btn-light" htmlFor="mode2" onClick={this.handlePlatformChange}>*/}
{/*<input type="radio" id="mode2" name="analysisMode"*/}
{/*value="PAIRS"*/}
{/*checked={this.state.analysisMode === "PAIRS"}/>Pairs</label>*/}
{/*<label className="btn btn-light" htmlFor="mode3" onClick={this.handlePlatformChange}>*/}
{/*<input type="radio" id="mode3" name="analysisMode"*/}
{/*value="FULL"*/}
{/*checked={this.state.analysisMode === "FULL"}/>Full</label>*/}
{/*</div>*/}
{/*</div>*/}
<div className="form-group">
<label htmlFor="moss-parameters">Default Moss parameters</label>
<div><input className="form-control" type="text" autoComplete="off" id="moss-parameters"
Expand All @@ -189,7 +173,7 @@ export class NewRepo extends React.Component {
<label htmlFor="filePatterns">File patterns</label>
<textarea className="form-control" id="filePatterns" name="filePatterns" value={this.state.filePatterns}
onChange={this.handleChange} rows="3"/>
<small id="emailHelp" className="form-text text-muted">Split regexps by new lines</small>
<small id="emailHelp" className="form-text text-muted">Split regexps by new lines. Leave empty to download all files.</small>
</div>
<div className="form-group">
<div className="custom-control custom-switch">
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const options = {

const AlertTemplate = ({style, options, message, close}) => (
<div className="alert-wrapper"><Alert className="shadow"
onDismiss={(e) => e.currentTarget.parentNode.remove()}>{message}</Alert></div>
onDismiss={(e) => e.currentTarget.parentNode
.parentNode.parentNode.remove()}>{message}</Alert></div>
);

Redirect("/repos");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package io.gitplag.model.entity

import com.fasterxml.jackson.annotation.JsonIgnore
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.JoinColumn
import javax.persistence.ManyToOne
import javax.persistence.*

/**
* Info class about stored solutions
Expand All @@ -22,7 +17,5 @@ data class SolutionFileRecord(
@JoinColumn(nullable = false)
val pullRequest: PullRequest,

val fileName: String,

val countOfLines: Int
val fileName: String
)

0 comments on commit 98d78ed

Please sign in to comment.