From 6526d636349bd730507af8c526e5f1e138f2a475 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 16 Dec 2016 14:13:58 -0500 Subject: Avoid unnescessary data pushes --- git-mirror-gitlab-ce | 14 ++++++++++++-- git-mirror-gitlab-ee | 7 +++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/git-mirror-gitlab-ce b/git-mirror-gitlab-ce index 6502618..80f0b81 100755 --- a/git-mirror-gitlab-ce +++ b/git-mirror-gitlab-ce @@ -101,7 +101,7 @@ class GitLabCE < GitMirrorBackend if self.info().nil? # create - libremessages('msg2', 'Creating repo %s', @project_id) + libremessages('msg2', 'Creating repo') namespace, path = @project_id.split('/', 2) namespace_id = namespace_path2id(namespace) @@ -122,7 +122,17 @@ class GitLabCE < GitMirrorBackend self.info = JSON::parse(res.body) else # update - libremessages('msg2', 'Updating repo %s metadata', @project_id) + mismatch = false + map.each do |key,val| + if self.info[key].to_s != val.to_s + mismatch = true + end + end + unless mismatch + libremessages('msg2', 'General metadata ok') + return nil + end + libremessages('msg2', 'Updating general metadata') req = Net::HTTP::Put.new(@gl.config['apiurl'] + "projects/" + CGI::escape(self.info["id"].to_s)) req.add_field("PRIVATE-TOKEN", @gl.config['apikey']) req.add_field("Content-Type", "application/json") diff --git a/git-mirror-gitlab-ee b/git-mirror-gitlab-ee index aaca9b7..2ec79f3 100755 --- a/git-mirror-gitlab-ee +++ b/git-mirror-gitlab-ee @@ -52,8 +52,11 @@ class GitLabEE < GitLabCE end def mirrorURL=(url) - libremessages('msg2', 'Setting mirror URL for %s', @project_id) - self.mirrorURL() + if self.mirrorURL == URI(url) + libremessages('msg2', 'Mirror URL ok') + return self.mirrorURL + end + libremessages('msg2', 'Setting mirror URL') req = Net::HTTP::Patch.new(URI(self.info["web_url"]+"/mirror")) req.add_field("PRIVATE-TOKEN", @gl.config['apikey']) # authenticate -- cgit v1.2.3-54-g00ecf