From 30430cf1c5785e15f93ed9547dd919e658289162 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 24 Mar 2015 16:28:49 -0300 Subject: Don't overwrite --detailed when given by the user. See https://twitter.com/Nymphium/status/580098018201882624 --- src/luarocks/write_rockspec.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/luarocks/write_rockspec.lua b/src/luarocks/write_rockspec.lua index fb3a120e..0a333123 100644 --- a/src/luarocks/write_rockspec.lua +++ b/src/luarocks/write_rockspec.lua @@ -83,18 +83,20 @@ local function detect_description(rockspec) fd:close() local paragraph = data:match("\n\n([^%[].-)\n\n") if not paragraph then paragraph = data:match("\n\n(.*)") end + local summary, detailed if paragraph then if #paragraph < 80 then - rockspec.description.summary = paragraph:gsub("\n", "") - rockspec.description.detailed = paragraph + summary = paragraph:gsub("\n", "") + detailed = paragraph else - local summary = paragraph:gsub("\n", " "):match("([^.]*%.) ") + local found_summary = paragraph:gsub("\n", " "):match("([^.]*%.) ") if summary then - rockspec.description.summary = summary:gsub("\n", "") + summary = found_summary:gsub("\n", "") end - rockspec.description.detailed = paragraph + detailed = paragraph end end + return summary, detailed end local function detect_mit_license(data) @@ -312,7 +314,11 @@ function write_rockspec.run(...) local ok, err = fs.change_dir(local_dir) if not ok then return nil, "Failed reaching files from project - error entering directory "..local_dir end - detect_description(rockspec) + if (not flags["summary"]) or (not flags["detailed"]) then + local summary, detailed = detect_description(rockspec) + rockspec.description.summary = flags["summary"] or summary + rockspec.description.detailed = flags["detailed"] or detailed + end local is_mit = show_license(rockspec) -- cgit v1.2.3-55-g6feb