Skip to content

Commit

Permalink
write gitattributes
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jul 2, 2020
1 parent 9758fd0 commit e77c8dc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
28 changes: 28 additions & 0 deletions SnoopCompileBot/src/precompile_include.jl
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,32 @@ function add_includer(package_name::AbstractString, package_path::AbstractString
@warn """SnoopCompileBot failed to add `"include(\"precompile_includer.jl\")"` to $package_path. You should do that manually!"""
end
end

# Add gitattributes to prevent line ending issues
gitattributes = """
# Set default behaviour to automatically normalize line endings.
* text=auto
# Force bash scripts to always use lf line endings so that if a repo is accessed
# in Unix via a file share from Windows, the scripts will work.
*.sh text eol=lf
"""
package_root_path = dirname(dirname(package_path))
gitattributes_path = "$package_root_path/.gitattributes"
if !isfile(gitattributes_path)
Base.write(gitattributes_path, gitattributes)
else
if !occursin("text=auto", Base.read(gitattributes_path, String))
gitattributes_lines = Base.open(gitattributes_path) do io
Base.readlines(io, keep=true)
end
append!(gitattributes_lines, gitattributes) # add new empty line before the end
open(gitattributes_path, "w") do io
for l in gitattributes_lines
Base.write(io, l)
end
end
end
end

end
9 changes: 9 additions & 0 deletions SnoopCompileBot/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ bottestdir = GoodPath(@__DIR__)

include("$(package_rootpath[1])/deps/SnoopCompile/snoop_bot.jl")

@test isfile("$(package_rootpath[1])/.gitattributes")
rm("$(package_rootpath[1])/.gitattributes", force=true)

@test isfile("$(package_rootpath[1])/deps/SnoopCompile/precompile/precompile_TestPackage1.jl")

precompile_text = Base.read("$(package_rootpath[1])/deps/SnoopCompile/precompile/precompile_TestPackage1.jl", String)
Expand All @@ -348,6 +351,9 @@ bottestdir = GoodPath(@__DIR__)

include("$(package_rootpath[2])/deps/SnoopCompile/snoop_bot.jl")

@test isfile("$(package_rootpath[2])/.gitattributes")
rm("$(package_rootpath[2])/.gitattributes", force=true)

@test isfile("$(package_rootpath[2])/deps/SnoopCompile/precompile/$os/precompile_TestPackage2.jl")

precompile_text = Base.read("$(package_rootpath[2])/deps/SnoopCompile/precompile/$os/precompile_TestPackage2.jl", String)
Expand All @@ -370,6 +376,9 @@ bottestdir = GoodPath(@__DIR__)

include("$(package_rootpath[3])/deps/SnoopCompile/snoop_bot.jl")

@test isfile("$(package_rootpath[3])/.gitattributes")
rm("$(package_rootpath[3])/.gitattributes", force=true)

@test isfile("$(package_rootpath[3])/deps/SnoopCompile/precompile/$(SnoopCompileBot.VersionFloat(VERSION))/precompile_TestPackage3.jl")

precompile_text = Base.read("$(package_rootpath[3])/deps/SnoopCompile/precompile/$(SnoopCompileBot.VersionFloat(VERSION))/precompile_TestPackage3.jl", String)
Expand Down

0 comments on commit e77c8dc

Please sign in to comment.