Class: Gitlab::Git::BundleFile
- Inherits:
-
Object
- Object
- Gitlab::Git::BundleFile
- Defined in:
- lib/gitlab/git/bundle_file.rb
Constant Summary collapse
- MAGIC =
All git bundle files start with one of these strings
"# v2 git bundle\n"- MAGIC_V3 =
"# v3 git bundle\n"- InvalidBundleError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Class Method Summary collapse
Instance Method Summary collapse
- #check! ⇒ Object
-
#initialize(filename) ⇒ BundleFile
constructor
A new instance of BundleFile.
Constructor Details
#initialize(filename) ⇒ BundleFile
Returns a new instance of BundleFile.
20 21 22 |
# File 'lib/gitlab/git/bundle_file.rb', line 20 def initialize(filename) @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
14 15 16 |
# File 'lib/gitlab/git/bundle_file.rb', line 14 def filename @filename end |
Class Method Details
.check!(filename) ⇒ Object
16 17 18 |
# File 'lib/gitlab/git/bundle_file.rb', line 16 def self.check!(filename) new(filename).check! end |
Instance Method Details
#check! ⇒ Object
24 25 26 27 28 |
# File 'lib/gitlab/git/bundle_file.rb', line 24 def check! data = File.open(filename, 'r') { |f| f.read(MAGIC.size) } raise InvalidBundleError, 'Invalid bundle file' unless data == MAGIC || data == MAGIC_V3 end |