aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormpeterv <mpeterval@gmail.com>2016-02-11 17:05:30 +0300
committermpeterv <mpeterval@gmail.com>2016-02-11 17:05:50 +0300
commit01040d6f731a8ef423f0e0a916f51616f2b1b9a1 (patch)
tree464f3812aa82ec1223a824f58aee688e18ab6a35 /src
parent137a78e3997cfb97131956d76ddb6b50bd3f8d24 (diff)
downloadluarocks-01040d6f731a8ef423f0e0a916f51616f2b1b9a1.tar.gz
luarocks-01040d6f731a8ef423f0e0a916f51616f2b1b9a1.tar.bz2
luarocks-01040d6f731a8ef423f0e0a916f51616f2b1b9a1.zip
Add --tag option for luarocks new_version
Allows using new_version command to create tagged rockspecs from untagged scm rockspecs. If not given, new version is copied from passed tag, with leading 'v' stripped if it's present.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/new_version.lua26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/luarocks/new_version.lua b/src/luarocks/new_version.lua
index fb813183..6969d4b2 100644
--- a/src/luarocks/new_version.lua
+++ b/src/luarocks/new_version.lua
@@ -1,9 +1,7 @@
1 1
2--- Module implementing the LuaRocks "new_version" command. 2--- Module implementing the LuaRocks "new_version" command.
3-- Utility function that writes a new rockspec, updating data from a previous one. 3-- Utility function that writes a new rockspec, updating data from a previous one.
4--module("luarocks.new_version", package.seeall)
5local new_version = {} 4local new_version = {}
6package.loaded["luarocks.new_version"] = new_version
7 5
8local util = require("luarocks.util") 6local util = require("luarocks.util")
9local download = require("luarocks.download") 7local download = require("luarocks.download")
@@ -13,7 +11,7 @@ local fs = require("luarocks.fs")
13local type_check = require("luarocks.type_check") 11local type_check = require("luarocks.type_check")
14 12
15new_version.help_summary = "Auto-write a rockspec for a new version of a rock." 13new_version.help_summary = "Auto-write a rockspec for a new version of a rock."
16new_version.help_arguments = "{<package>|<rockspec>} [<new_version>] [<new_url>]" 14new_version.help_arguments = "[--tag=<tag>] {<package>|<rockspec>} [<new_version>] [<new_url>]"
17new_version.help = [[ 15new_version.help = [[
18This is a utility function that writes a new rockspec, updating data 16This is a utility function that writes a new rockspec, updating data
19from a previous one. 17from a previous one.
@@ -21,8 +19,10 @@ from a previous one.
21If a package name is given, it downloads the latest rockspec from the 19If a package name is given, it downloads the latest rockspec from the
22default server. If a rockspec is given, it uses it instead. 20default server. If a rockspec is given, it uses it instead.
23 21
24If the version number is not given, it only increments the revision 22If the version number is not given and tag is passed using --tag,
25number of the given (or downloaded) rockspec. 23it is used as the version, with 'v' removed from beginning.
24Otherwise, it only increments the revision number of the given
25(or downloaded) rockspec.
26 26
27If a URL is given, it replaces the one from the old rockspec with the 27If a URL is given, it replaces the one from the old rockspec with the
28given URL. If a URL is not given and a new version is given, it tries 28given URL. If a URL is not given and a new version is given, it tries
@@ -30,6 +30,9 @@ to guess the new URL by replacing occurrences of the version number
30in the URL or tag. It also tries to download the new URL to determine 30in the URL or tag. It also tries to download the new URL to determine
31the new MD5 checksum. 31the new MD5 checksum.
32 32
33If a tag is given, it replaces the one from the old rockspec. If there is
34an old tag but no new one passed, it is guessed in the same way URL is.
35
33WARNING: it writes the new rockspec to the current directory, 36WARNING: it writes the new rockspec to the current directory,
34overwriting the file if it already exists. 37overwriting the file if it already exists.
35]] 38]]
@@ -85,7 +88,10 @@ local function check_url_and_update_md5(out_rs)
85 end 88 end
86end 89end
87 90
88local function update_source_section(out_rs, url, old_ver, new_ver) 91local function update_source_section(out_rs, url, tag, old_ver, new_ver)
92 if tag then
93 out_rs.source.tag = tag
94 end
89 if url then 95 if url then
90 out_rs.source.url = url 96 out_rs.source.url = url
91 return check_url_and_update_md5(out_rs) 97 return check_url_and_update_md5(out_rs)
@@ -102,7 +108,7 @@ local function update_source_section(out_rs, url, old_ver, new_ver)
102 if try_replace(out_rs.source, "url", old_ver, new_ver) then 108 if try_replace(out_rs.source, "url", old_ver, new_ver) then
103 return check_url_and_update_md5(out_rs) 109 return check_url_and_update_md5(out_rs)
104 end 110 end
105 if try_replace(out_rs.source, "tag", old_ver, new_ver) then 111 if tag or try_replace(out_rs.source, "tag", old_ver, new_ver) then
106 return true 112 return true
107 end 113 end
108 -- Couldn't replace anything significant, use the old URL. 114 -- Couldn't replace anything significant, use the old URL.
@@ -139,6 +145,10 @@ function new_version.run(...)
139 145
140 local old_ver, old_rev = valid_rs.version:match("(.*)%-(%d+)$") 146 local old_ver, old_rev = valid_rs.version:match("(.*)%-(%d+)$")
141 local new_ver, new_rev 147 local new_ver, new_rev
148
149 if flags.tag and not version then
150 version = flags.tag:gsub("^v", "")
151 end
142 152
143 if version then 153 if version then
144 new_ver, new_rev = version:match("(.*)%-(%d+)$") 154 new_ver, new_rev = version:match("(.*)%-(%d+)$")
@@ -157,7 +167,7 @@ function new_version.run(...)
157 local out_name = out_rs.package:lower() 167 local out_name = out_rs.package:lower()
158 out_rs.version = new_rockver.."-"..new_rev 168 out_rs.version = new_rockver.."-"..new_rev
159 169
160 local ok, err = update_source_section(out_rs, url, old_ver, new_ver) 170 local ok, err = update_source_section(out_rs, url, flags.tag, old_ver, new_ver)
161 if not ok then return nil, err end 171 if not ok then return nil, err end
162 172
163 if out_rs.build and out_rs.build.type == "module" then 173 if out_rs.build and out_rs.build.type == "module" then