<commit_before>#!/usr/bin/env ruby

require 'yaml'

gpg_public_keys = { "gpg_public_keys" => [] }

public_key_ids = File.read('./.gpg-id')
public_key_ids.each_line do |id|
  # Assert key can be found locally
  `gpg -k #{id}`
  if $?.exitstatus != 0
    puts "This key needs to be imported: #{id}"
    puts """Try running
    gpg --recv #{id}
    """
    exit $?.exitstatus
  end
  public_key = `gpg --armor --export-options export-minimal --export #{id}`
  gpg_public_keys["gpg_public_keys"] << public_key
end

output_file = './concourse/vars-files/gpg-keys.yml'
output = gpg_public_keys.to_yaml
annotated_output = """# THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT EDIT
# See https://team-manual.cloud.service.gov.uk/team/working_practices/#merging-pull-requests
#{output}"""
File.write(output_file, annotated_output)
puts "Public keys written to #{output_file}"<commit_msg>Improve public key generation script<commit_after>#!/usr/bin/env ruby

require 'yaml'

gpg_public_keys = { "gpg_public_keys" => [] }

public_key_ids = File.read('./.gpg-id')
public_key_ids.each_line do |id|
  # Assert key can be found locally
  `gpg -k #{id}`
  if $?.exitstatus != 0
    puts "This key needs to be imported: #{id}"
    puts """Try running
    gpg --recv #{id}
    """
    exit $?.exitstatus
  end
  public_key = `gpg --armor --export-options export-minimal --export #{id}`
  gpg_public_keys["gpg_public_keys"] << public_key
end

output_file = './concourse/vars-files/gpg-keys.yml'
output = gpg_public_keys.to_yaml
annotated_output = """# THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT EDIT
# See https://team-manual.cloud.service.gov.uk/team/working_practices/#merging-pull-requests
#{output}"""
File.write(output_file, annotated_output)
puts "Public keys written to #{output_file}"
puts "Note: we don't yet have a way of producing a canonical output via GPG, so when you run this script you may see changes to everybody's public keys. These differences are okay to commit - what matters is they are derived from the correct public key IDs."
{'fraction_non_alphanumeric': 0.1343503937007874, 'fraction_numerical': 0.000984251968503937, 'mean_word_length': 4.159898477157361, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4617483', 'n_tokens_mistral': 708, 'n_tokens_neox': 689, 'n_words': 198}