aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormpeterv <mpeterval@gmail.com>2015-03-26 13:30:04 +0300
committermpeterv <mpeterval@gmail.com>2015-03-26 13:33:32 +0300
commit050d6568fa935cc4664876a69c8662449986550f (patch)
tree4b7bfea1c9fd9f5c80e061de3722e2bb54aaa69e
parent4ad1f1a1e3f460eaacb3e181bf3932431f45596f (diff)
downloadluarocks-050d6568fa935cc4664876a69c8662449986550f.tar.gz
luarocks-050d6568fa935cc4664876a69c8662449986550f.tar.bz2
luarocks-050d6568fa935cc4664876a69c8662449986550f.zip
Fix summary detection in long paragraphs
* `if summary then` branch was never taken as `summary` isn't assigned by then * Removing newlines in summary is useless since they have been replced with space already * `detect_description()` doesn't use rockspec argument any more
-rw-r--r--src/luarocks/write_rockspec.lua13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/luarocks/write_rockspec.lua b/src/luarocks/write_rockspec.lua
index 0a333123..68942e07 100644
--- a/src/luarocks/write_rockspec.lua
+++ b/src/luarocks/write_rockspec.lua
@@ -76,7 +76,7 @@ local function configure_lua_version(rockspec, luaver)
76 end 76 end
77end 77end
78 78
79local function detect_description(rockspec) 79local function detect_description()
80 local fd = open_file("README.md") or open_file("README") 80 local fd = open_file("README.md") or open_file("README")
81 if not fd then return end 81 if not fd then return end
82 local data = fd:read("*a") 82 local data = fd:read("*a")
@@ -85,15 +85,12 @@ local function detect_description(rockspec)
85 if not paragraph then paragraph = data:match("\n\n(.*)") end 85 if not paragraph then paragraph = data:match("\n\n(.*)") end
86 local summary, detailed 86 local summary, detailed
87 if paragraph then 87 if paragraph then
88 detailed = paragraph
89
88 if #paragraph < 80 then 90 if #paragraph < 80 then
89 summary = paragraph:gsub("\n", "") 91 summary = paragraph:gsub("\n", "")
90 detailed = paragraph
91 else 92 else
92 local found_summary = paragraph:gsub("\n", " "):match("([^.]*%.) ") 93 summary = paragraph:gsub("\n", " "):match("([^.]*%.) ")
93 if summary then
94 summary = found_summary:gsub("\n", "")
95 end
96 detailed = paragraph
97 end 94 end
98 end 95 end
99 return summary, detailed 96 return summary, detailed
@@ -315,7 +312,7 @@ function write_rockspec.run(...)
315 if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end 312 if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end
316 313
317 if (not flags["summary"]) or (not flags["detailed"]) then 314 if (not flags["summary"]) or (not flags["detailed"]) then
318 local summary, detailed = detect_description(rockspec) 315 local summary, detailed = detect_description()
319 rockspec.description.summary = flags["summary"] or summary 316 rockspec.description.summary = flags["summary"] or summary
320 rockspec.description.detailed = flags["detailed"] or detailed 317 rockspec.description.detailed = flags["detailed"] or detailed
321 end 318 end