Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const diffToGitJSONDSL = (diff: string, commits: GitCommit[]): GitJSONDSL => {
const fileDiffs: any[] = parseDiff(diff)
const addedDiffs = fileDiffs.filter((diff: any) => diff["new"])
const removedDiffs = fileDiffs.filter((diff: any) => diff["deleted"])
const modifiedDiffs = fileDiffs.filter((diff: any) => !includes(addedDiffs, diff) && !includes(removedDiffs, diff))
return {
// Work around for danger/danger-js#807
modified_files: modifiedDiffs.map(d => d.to || (d.from && d.from.split(" b/")[0])),
created_files: addedDiffs.map(d => d.to),
deleted_files: removedDiffs.map(d => d.from),
commits: commits,
}
}
function parseDeleteAndNormalLines(diffData, fileToDeletedLinesMap, fileToNormalLinesMap) {
try {
console.log('parseDeleteAndNormalLines')
var diffs = parseDiff(diffData)
console.log('diffs:'+diffs)
if(diffs&&diffs instanceof Array){
diffs.forEach(diff => {
fileToDeletedLinesMap[diff.from] = [];
fileToNormalLinesMap[diff.from] = [];
if(diff&&diff.chunks&&diff.chunks instanceof Array){
diff.chunks.forEach(chunk => {
if(chunk&&chunk.changes&&chunk.changes instanceof Array){
chunk.changes.forEach(change => {
if (change&&change.del) {
fileToDeletedLinesMap[diff.from].push(change.ln)
}
if (change&&change.normal) {
fileToNormalLinesMap[diff.from].push(change.ln1)
}
})
renderHeader = () => {
const { navigation } = this.props;
const { locale, diff } = navigation.state.params;
const filesChanged = Parse(diff);
let lineAdditions = 0;
let lineDeletions = 0;
filesChanged.forEach(file => {
lineAdditions += file.additions;
lineDeletions += file.deletions;
});
return (
const structuredDiffForFile = async (filename: string): Promise => {
let fileDiffs: GitStructuredDiff
if (config.getStructuredDiffForFile) {
fileDiffs = await config.getStructuredDiffForFile(config.baseSHA, config.headSHA, filename)
} else {
const diff = await getFullDiff!(config.baseSHA, config.headSHA)
fileDiffs = parseDiff(diff)
}
const structuredDiff = fileDiffs.find(diff => diff.from === filename || diff.to === filename)
if (structuredDiff !== undefined && structuredDiff.chunks !== undefined) {
return { chunks: structuredDiff.chunks }
} else {
return null
}
}
render() {
const { navigation } = this.props;
const filesChanged = navigation.state.params
? Parse(navigation.state.params.diff)
: [];
return (
);
}
}
diff,
issue,
commits,
repository,
isMergeable,
isMerged,
isPendingDiff,
isPendingCommit,
isPendingCheckMerge,
onRepositoryPress,
userHasPushPermission,
locale,
navigation,
} = this.props;
const filesChanged = Parse(diff);
let lineAdditions = 0;
let lineDeletions = 0;
filesChanged.forEach(file => {
lineAdditions += file.additions;
lineDeletions += file.deletions;
});
return (
{issue.repository_url && (