diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2023-06-27 11:41:43 -0400 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2023-06-27 11:41:43 -0400 |
commit | 1c1de88d2603ebc137ab57218fcdd45935086946 (patch) | |
tree | 0deb869edc78ec435e03b6d2aaefc549093d9b13 | |
parent | 74b06c33ba41a24f4832439828b4e90c6a753f10 (diff) | |
download | lite-xl-plugin-manager-1c1de88d2603ebc137ab57218fcdd45935086946.tar.gz lite-xl-plugin-manager-1c1de88d2603ebc137ab57218fcdd45935086946.zip |
Added in shallow cloning.
m--------- | lib/libgit2 | 0 | ||||
-rw-r--r-- | src/lpm.c | 5 | ||||
-rw-r--r-- | src/lpm.lua | 13 |
3 files changed, 14 insertions, 4 deletions
diff --git a/lib/libgit2 b/lib/libgit2 -Subproject 12832bab7363e92bfa45d1ef3c3bc10495d71ab +Subproject f041a94e2c358e84adb5a0fe108288fcb380297 @@ -425,14 +425,17 @@ static int lpm_fetch(lua_State* L) { git_repository_free(repository); return luaL_error(L, "git remote fetch error: %s", git_error_last_string()); } + const char* refspec = lua_gettop(L) >= 3 ? luaL_checkstring(L, 3) : NULL; git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT; fetch_opts.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL; fetch_opts.callbacks.payload = L; + fetch_opts.depth = 1; if (no_verify_ssl) fetch_opts.callbacks.certificate_check = lpm_git_transport_certificate_check_cb; if (lua_type(L, 2) == LUA_TFUNCTION) fetch_opts.callbacks.transfer_progress = lpm_git_transfer_progress_cb; - if (git_remote_fetch(remote, NULL, &fetch_opts, NULL)) { + git_strarray array = { &refspec, 1 }; + if (git_remote_fetch(remote, refspec ? &array : NULL, &fetch_opts, NULL)) { git_remote_free(remote); git_repository_free(repository); return luaL_error(L, "git remote fetch error: %s", git_error_last_string()); diff --git a/src/lpm.lua b/src/lpm.lua index f5f2824..a4a4373 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -1142,7 +1142,11 @@ function Repository:fetch() end if not exists or self.branch then log_progress_action("Fetching " .. self.remote .. ":" .. (self.commit or self.branch) .. "...") - system.fetch(temporary_path or path, write_progress_bar) + if self.commit then + system.fetch(temporary_path or path, write_progress_bar, self.commit) + elseif self.branch then + system.fetch(temporary_path or path, write_progress_bar, "+refs/heads/" .. self.branch .. ":refs/remotes/origin/" .. self.branch) + end common.reset(temporary_path or path, self.commit or self.branch, "hard") end self.manifest = nil @@ -1181,9 +1185,9 @@ end function Repository:update(pull_remotes) local manifest, remotes = self:parse_manifest() if self.branch then - system.fetch(self.local_path) + log_progress_action("Updating " .. self:url() .. "...") + system.fetch(self.local_path, write_progress_bar, "+refs/heads/" .. self.branch .. ":refs/remotes/origin/" .. self.branch) common.reset(self.local_path, self.branch, "hard") - log_action("Updated " .. self:url() .. ".", "green") self.manifest = nil manifest, remotes = self:parse_manifest() end @@ -2093,6 +2097,7 @@ not commonly used publically. if type(total_read) == "boolean" then io.stdout:write(json.encode({ progress = { percent = 1, label = progress_bar_label } }) .. "\n") io.stdout:flush() + last_read = nil return end if not last_read then last_read = system.time() end @@ -2105,8 +2110,10 @@ not commonly used publically. else write_progress_bar = function(total_read, total_objects_or_content_length, indexed_objects, received_objects, local_objects, local_deltas, indexed_deltas) if type(total_read) == "boolean" then + if not last_read then io.stdout:write(progress_bar_label) end io.stdout:write("\n") io.stdout:flush() + last_read = nil return end if not start_time or total_read < last_read then start_time = system.time() end |