From a5be3573a96ac41105f359b964be1409a31a9944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=D0=BD=20=D0=94=D0=BE=D0=BD=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Sun, 24 Jan 2016 23:04:05 +0300 Subject: [PATCH] Normalize EOL to CRLF when building a source distribution --- build.gradle | 5 +---- buildSrc/build.gradle | 4 ++-- buildSrc/src/main/groovy/BuildUtils.groovy | 9 +++++++-- buildSrc/src/main/groovy/ExportedFileInfo.groovy | 5 +++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index dd184d4..e5c642d 100644 --- a/build.gradle +++ b/build.gradle @@ -144,10 +144,7 @@ task configureDistSource << { distSource.from(f.path) { into RelativePath.parse(true, f.path).parent.pathString if (f.executable) fileMode 0755 - // TODO: apply the CrLf filter where appropriate. Unfortunately, this will be very difficult - // to do until JGit adds better attribute support (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=342372). - // More specifically, we need to be able to query attributes for the current TreeWalk position - // (implemented by https://git.eclipse.org/r/#/c/35377/). + if (f.containsNativeText) filter(FixCrLfFilter, eol: exportEOL) } } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 2d1d654..a12a6b5 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,6 +1,6 @@ /* This file is part of Octetoscope. - Copyright (C) 2013-2015 Octetoscope contributors (see /AUTHORS.txt) + Copyright (C) 2013-2016 Octetoscope contributors (see /AUTHORS.txt) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,5 +24,5 @@ repositories { } dependencies { - compile 'org.eclipse.jgit:org.eclipse.jgit:3.6.0.201412230720-r' + compile 'org.eclipse.jgit:org.eclipse.jgit:4.2.0.201601211800-r' } diff --git a/buildSrc/src/main/groovy/BuildUtils.groovy b/buildSrc/src/main/groovy/BuildUtils.groovy index 5c826ba..33e9533 100644 --- a/buildSrc/src/main/groovy/BuildUtils.groovy +++ b/buildSrc/src/main/groovy/BuildUtils.groovy @@ -1,6 +1,6 @@ /* This file is part of Octetoscope. - Copyright (C) 2013-2015 Octetoscope contributors (see /AUTHORS.txt) + Copyright (C) 2013-2016 Octetoscope contributors (see /AUTHORS.txt) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -117,7 +117,12 @@ public final class BuildUtils { if (mode != FileMode.REGULAR_FILE && mode != FileMode.EXECUTABLE_FILE) throw new RuntimeException("Can't export an entry with mode $mode.") - results.add(new ExportedFileInfo(path: wtItem.entryPathString, executable: mode == FileMode.EXECUTABLE_FILE)) + def attrs = treeWalk.getAttributes() + + results.add(new ExportedFileInfo( + path: wtItem.entryPathString, + executable: mode == FileMode.EXECUTABLE_FILE, + containsNativeText: !attrs.isCustom("eol") && attrs.isSet("text"))) } return results diff --git a/buildSrc/src/main/groovy/ExportedFileInfo.groovy b/buildSrc/src/main/groovy/ExportedFileInfo.groovy index e6392a5..bf58cbb 100644 --- a/buildSrc/src/main/groovy/ExportedFileInfo.groovy +++ b/buildSrc/src/main/groovy/ExportedFileInfo.groovy @@ -1,6 +1,6 @@ /* This file is part of Octetoscope. - Copyright (C) 2015 Octetoscope contributors (see /AUTHORS.txt) + Copyright (C) 2015-2016 Octetoscope contributors (see /AUTHORS.txt) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,9 +19,10 @@ public final class ExportedFileInfo { String path boolean executable + boolean containsNativeText @Override String toString() { - return "$path${executable ? " (executable)" : ""}" + return "$path${executable ? " (executable)" : ""}${containsNativeText ? " (native text)" : ""}" } }