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 this string
"# v2 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.
19 20 21 |
# File 'lib/gitlab/git/bundle_file.rb', line 19 def initialize(filename) @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
13 14 15 |
# File 'lib/gitlab/git/bundle_file.rb', line 13 def filename @filename end |
Class Method Details
.check!(filename) ⇒ Object
15 16 17 |
# File 'lib/gitlab/git/bundle_file.rb', line 15 def self.check!(filename) new(filename).check! end |
Instance Method Details
#check! ⇒ Object
23 24 25 26 27 |
# File 'lib/gitlab/git/bundle_file.rb', line 23 def check! data = File.open(filename, 'r') { |f| f.read(MAGIC.size) } raise InvalidBundleError, 'Invalid bundle file' unless data == MAGIC end |