• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / pdc_discovery / 55dfdc6d-52fd-4703-9abe-dc34d2f969dd

14 Aug 2025 12:10AM UTC coverage: 96.873% (-0.1%) from 97.006%
55dfdc6d-52fd-4703-9abe-dc34d2f969dd

Pull #818

circleci

web-flow
Bump activestorage from 7.2.2.1 to 7.2.2.2

Bumps [activestorage](https://github.com/rails/rails) from 7.2.2.1 to 7.2.2.2.
- [Release notes](https://github.com/rails/rails/releases)
- [Changelog](https://github.com/rails/rails/blob/v8.0.2.1/activestorage/CHANGELOG.md)
- [Commits](https://github.com/rails/rails/compare/v7.2.2.1...v7.2.2.2)

---
updated-dependencies:
- dependency-name: activestorage
  dependency-version: 7.2.2.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #818: Bump activestorage from 7.2.2.1 to 7.2.2.2

2912 of 3006 relevant lines covered (96.87%)

116.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.75
/app/models/version_footer.rb
1
# frozen_string_literal: true
2

3
# Retrieves version information from Capistrano's files. The general approach is
4
# to read the version information (branch name, git SHA, and date deployed) out
5
# of Capistrano's revisions.log file.
6
#
7
# The code is a bit more complicated than it should because Capistrano does not
8
# always update the revision.log file before the application reads this information.
9
# Therefore there is logic in this class to detect if the version information is
10
# stale and re-read it until it is up to date. Because re-reading this file is
11
# an expensive operation we cache the information as soon as we are sure it's
12
# current.
13
#
14
# rubocop:disable Style/ClassVars
15
class VersionFooter
1✔
16
  DEPLOYMENT_LOGFILE_COL_NUMBER = 7
1✔
17
  REVISIONS_LOG_COL = 3
1✔
18
  DEFAULT_SHA = "Unknown SHA"
1✔
19

20
  @@stale = true
1✔
21
  @@git_sha = nil
1✔
22
  @@branch = nil
1✔
23
  @@version = nil
1✔
24

25
  # Returns a hash with version information.
26
  def self.info
1✔
27
    reset! if stale?
75✔
28
    { sha: git_sha, branch: branch, version: version, stale: stale?, tagged_release: tagged_release? }
75✔
29
  end
30

31
  def self.reset!
1✔
32
    # Initalize these values so that they recalculated
33
    @@git_sha = nil
5✔
34
    @@branch = nil
5✔
35
    @@version = nil
5✔
36

37
    @@local_sha = nil
5✔
38
    @@revisions = nil
5✔
39

40
    @@git_sha = nil
5✔
41
    @@revisions_head = nil
5✔
42
    @@revisions_log = nil
5✔
43
  end
44

45
  def self.revisions
1✔
46
    return unless File.exist?(revision_file)
303✔
47

48
    @@revisions ||= File.read(revision_file).chomp
303✔
49
  end
50

51
  def self.local_sha
1✔
52
    return unless revisions
300✔
53

54
    @@local_sha ||= revisions.gsub(/\)$/, '')
300✔
55
  end
56

57
  def self.revisions_log
1✔
58
    return unless File.exist?(revisions_logfile)
3✔
59

60
    content = `tail -1 #{revisions_logfile}`.chomp
3✔
61
    elements = content.split(" ")
3✔
62
    return if elements.length < REVISIONS_LOG_COL
3✔
63

64
    element = elements[REVISIONS_LOG_COL]
3✔
65
    @@revisions_log ||= element.gsub(/\)$/, '')
3✔
66
  end
67

68
  def self.revisions_head
1✔
69
    return unless Rails.env.development? || Rails.env.test?
×
70

71
    @@revisions_head ||= `git rev-parse HEAD`.chomp
×
72
  end
73

74
  def self.git_sha
1✔
75
    @@git_sha ||= revisions_log || revisions_head || DEFAULT_SHA
225✔
76
  end
77

78
  def self.stale?
1✔
79
    return false unless local_sha
150✔
80

81
    local_sha != git_sha
150✔
82
  end
83

84
  def self.tagged_release?
1✔
85
    # e.g. v0.8.0
86
    branch.match(/^v[\d+\.+]+/) != nil
75✔
87
  end
88

89
  def self.branch
1✔
90
    @@branch ||= if File.exist?(revisions_logfile)
150✔
91
                   `tail -1 #{revisions_logfile}`.chomp.split(" ")[1]
2✔
92
                 elsif Rails.env.development? || Rails.env.test?
×
93
                   `git rev-parse --abbrev-ref HEAD`.chomp
×
94
                 else
95
                   "Unknown branch"
×
96
                 end
97
  end
98

99
  def self.find_version
1✔
100
    return "Not in deployed environment" unless File.exist?(revisions_logfile)
2✔
101

102
    output = `tail -1 #{revisions_logfile}`
2✔
103
    entries = output.chomp.split(" ")
2✔
104
    return "(Deployment date could not be parsed from: #{output}.)" if entries.length <= DEPLOYMENT_LOGFILE_COL_NUMBER
2✔
105

106
    deployment_entry = entries[DEPLOYMENT_LOGFILE_COL_NUMBER]
1✔
107
    deployment_date = Date.parse(deployment_entry)
1✔
108
    return "(Deployment date could not be parsed from: #{deployment_entry}.)" if deployment_date.nil?
1✔
109

110
    formatted = deployment_date.strftime("%d %B %Y")
1✔
111
    formatted
1✔
112
  end
113

114
  def self.version
1✔
115
    @@version ||= find_version
75✔
116
  end
117

118
  # This file is local to the application.
119
  # This file only has the git SHA of the version deployed (i.e. no date or branch)
120
  def self.revision_file
1✔
121
    @@revision_file ||= Rails.root.join("REVISION")
306✔
122
  end
123

124
  # Capistrano keeps this file a couple of levels up _outside_ the application.
125
  # This file includes all the information that we need (git SHA, branch name, date)
126
  def self.revisions_logfile
1✔
127
    @@revisions_logfile ||= Rails.root.join("..", "..", "revisions.log")
14✔
128
  end
129

130
  # These assignment methods are needed to facilitate testing
131
  def self.revision_file=(x)
1✔
132
    @@revision_file = x
2✔
133
  end
134

135
  def self.revisions_logfile=(x)
1✔
136
    @@revisions_logfile = x
2✔
137
  end
138
end
139
# rubocop:enable RuboCop::Cop::Style::ClassVars
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc