Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2022-11-25 13:59:34 +0300
committerToon Claes <toon@gitlab.com>2022-11-28 11:55:57 +0300
commit89a75c3bd71098df4e3003ef56a5ba670e13c58a (patch)
tree5ae07b9dfde87d12ed7455fe8026bbcf04a6bf04 /ruby
parent6a42ae58732e12e145dfbb473d7029b887d70ca6 (diff)
ruby: Remove bin/gitaly-linguist script
In the previous release we stopped using the github-linguist gem completely, so now it's safe to remove the Ruby script we wrote to use that gem.
Diffstat (limited to 'ruby')
-rwxr-xr-xruby/bin/gitaly-linguist86
1 files changed, 0 insertions, 86 deletions
diff --git a/ruby/bin/gitaly-linguist b/ruby/bin/gitaly-linguist
deleted file mode 100755
index f06e29b35..000000000
--- a/ruby/bin/gitaly-linguist
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-require 'json'
-require 'linguist'
-require 'optparse'
-require 'rugged'
-require 'tempfile'
-require 'zlib'
-
-LANGUAGE_STATS_CACHE = 'language-stats.cache'
-LANGUAGE_STATS_CACHE_VERSION = "v3:#{Linguist::VERSION}"
-
-def gitaly_linguist(args)
- repository_path = nil
- commit = nil
-
- parser = OptionParser.new do |opts|
- opts.on("-rREPOSITORY", "--repository=REPOSITORY", "Repository to scan") { |r| repository_path = r }
- opts.on("-cCOMMIT", "--commit=COMMIT", "Commit to scan") { |c| commit = c }
- opts.on("-h", "--help", "Prints this help") do
- puts opts
- exit
- end
- end
-
- parser.parse!(args)
-
- raise OptionParser::MissingArgument, 'repository' if repository_path.nil?
- raise OptionParser::MissingArgument, 'commit' if commit.nil?
-
- Rugged::Settings['search_path_system'] = '/dev/null'
- Rugged::Settings['search_path_global'] = '/dev/null'
- Rugged::Settings['search_path_xdg'] = '/dev/null'
-
- repository = Rugged::Repository.bare(repository_path)
- project = Linguist::Repository.new(repository, commit)
-
- if (cache = load_cache(repository_path))
- old_commit_oid, old_stats = cache
-
- project.load_existing_stats(old_commit_oid, old_stats)
- end
-
- puts JSON.dump(project.languages)
-
- write_cache(repository_path, commit, project.cache)
-end
-
-def cache_file(repo_path)
- File.join(repo_path, LANGUAGE_STATS_CACHE)
-end
-
-def load_cache(repo_path)
- cached_data = File.open(cache_file(repo_path), "rb") do |f|
- Zlib::Inflate.inflate(f.read)
- end
-
- # rubocop:disable Security/MarshalLoad
- #
- # While this is ugly, it's the same as we previously did in git-linguist. So
- # for backwards-compatibility reasons we can't change this.
- version, commit, stats = Marshal.load(cached_data)
- # rubocop:enable Security/MarshalLoad
-
- if version == LANGUAGE_STATS_CACHE_VERSION && commit && stats
- [commit, stats]
- end
-rescue SystemCallError, ::Zlib::DataError, ::Zlib::BufError, TypeError
- nil
-end
-
-def write_cache(repo_path, commit, stats)
- cache = [LANGUAGE_STATS_CACHE_VERSION, commit, stats]
-
- Tempfile.open('cache_file', repo_path) do |f|
- marshal = Marshal.dump(cache)
- f.write(Zlib::Deflate.deflate(marshal))
- f.close
- File.rename(f.path, cache_file(repo_path))
- end
-
- FileUtils.chmod 0o644, cache_file(repo_path)
-end
-
-gitaly_linguist(ARGV)