forked from JuliaLang/METADATA.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remaster.jl
executable file
·48 lines (43 loc) · 1.56 KB
/
remaster.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env julia
include(joinpath(JULIA_HOME,"../../base/pkg1.jl"))
using Pkg1.Metadata
const fixed = Version("julia",v"0.1")
readchomp(`git rev-parse --symbolic-full-name --abbrev-ref HEAD`) == "devel" ||
error("not on devel branch.")
success(`git diff --quiet HEAD`) ||
error("git state not clean.")
for pkg in eachline(`ls`)
pkg = chomp(pkg)
isdir(pkg) && isfile("$pkg/url") || continue
vers = String[]
for ver in eachline(`ls $pkg/versions`)
ver = chomp(ver)
ismatch(Base.VERSION_REGEX,ver) || continue
push!(vers,ver)
isfile("$pkg/versions/$ver/requires") || continue
reqs = parse_requires("$pkg/versions/$ver/requires")
for r in reqs
if r.package == "julia" && !contains(r,fixed)
run(`rm -rf $pkg/versions/$ver`)
filter!(v->v!=ver,vers)
end
end
isdir("$pkg/versions/$ver") || continue
run(`perl -i -ple 's/^\s*(julia\b.*?)\s*$/# $1/' $pkg/versions/$ver/requires`)
end
isempty(vers) && run(`rm -rf $pkg`)
end
run(`git add -u`)
tree = readchomp(`git write-tree`)
if success(`git diff --quiet master $tree`)
run(`git checkout -f`)
info("no changes to apply to master, still on devel.")
else
run(`git checkout -f master`)
run(`git pull`)
master = readchomp(`git rev-parse master`)
devel = readchomp(`git rev-parse devel`)
commit = readchomp(`echo Remaster merge` | `git commit-tree $tree -p $master -p $devel`)
run(`git reset --hard $commit`)
info("remastered state committed to master.")
end