diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-01-02 15:42:57 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-01-02 15:42:57 -0200 |
| commit | 53a54bbb10e75f9ac2e754d9292cfb080f53b69d (patch) | |
| tree | 4244b8a3b2232153a297c78d2a31ea05b35e4999 /src | |
| parent | fa5fa1bf6b8df533a60a8675b38ac547a7c0b34a (diff) | |
| download | luarocks-53a54bbb10e75f9ac2e754d9292cfb080f53b69d.tar.gz luarocks-53a54bbb10e75f9ac2e754d9292cfb080f53b69d.tar.bz2 luarocks-53a54bbb10e75f9ac2e754d9292cfb080f53b69d.zip | |
Obtain a unique identifier for a rock version fetched via git
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fetch/git.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index edc11762..2b8adc78 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
| @@ -50,6 +50,17 @@ local function git_supports_shallow_submodules(git_cmd) | |||
| 50 | return git_is_at_least(git_cmd, "1.8.4") | 50 | return git_is_at_least(git_cmd, "1.8.4") |
| 51 | end | 51 | end |
| 52 | 52 | ||
| 53 | local function git_identifier(git_cmd, ver) | ||
| 54 | if not (ver:match("^dev%-%d+$") or ver:match("^scm%-%d+$")) then | ||
| 55 | return nil | ||
| 56 | end | ||
| 57 | local date_hash = util.popen_read(fs.Q(git_cmd).." log --pretty=format:'%ai %h' -n 1") | ||
| 58 | local date, time, tz, hash = date_hash:match("([^%s]+) ([^%s]+) ([^%s]+) ([^%s]+)") | ||
| 59 | date = date:gsub("%-", "") | ||
| 60 | time = time:gsub(":", "") | ||
| 61 | return date .. "." .. time .. "." .. hash | ||
| 62 | end | ||
| 63 | |||
| 53 | --- Download sources for building a rock, using git. | 64 | --- Download sources for building a rock, using git. |
| 54 | -- @param rockspec table: The rockspec table | 65 | -- @param rockspec table: The rockspec table |
| 55 | -- @param extract boolean: Unused in this module (required for API purposes.) | 66 | -- @param extract boolean: Unused in this module (required for API purposes.) |
| @@ -122,6 +133,10 @@ function git.get_sources(rockspec, extract, dest_dir, depth) | |||
| 122 | return nil, 'Failed to fetch submodules.' | 133 | return nil, 'Failed to fetch submodules.' |
| 123 | end | 134 | end |
| 124 | end | 135 | end |
| 136 | |||
| 137 | if not rockspec.source.tag then | ||
| 138 | rockspec.source.identifier = git_identifier(git_cmd, rockspec.version) | ||
| 139 | end | ||
| 125 | 140 | ||
| 126 | fs.delete(dir.path(store_dir, module, ".git")) | 141 | fs.delete(dir.path(store_dir, module, ".git")) |
| 127 | fs.delete(dir.path(store_dir, module, ".gitignore")) | 142 | fs.delete(dir.path(store_dir, module, ".gitignore")) |
