File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ def detect
4343 tags = tag_detection ( 'container' , @containers , true )
4444 tags . concat tag_detection ( 'JRE' , @jres , true ) unless tags . empty?
4545 tags . concat tag_detection ( 'framework' , @frameworks , false ) unless tags . empty?
46- tags = tags . flatten . compact
46+ tags << "java-buildpack=#{ @buildpack_version . to_s false } " unless tags . empty?
47+ tags = tags . flatten . compact . sort
4748
4849 @logger . debug { "Detection Tags: #{ tags } " }
4950 tags
Original file line number Diff line number Diff line change @@ -45,15 +45,18 @@ def initialize
4545 # +abcde | https://github.com/cloudfoundry/java-buildpack.git#abcde+ (default version number, online buildpack)
4646 # +https://github.com/cloudfoundry/java-buildpack#12345+ (cloned buildpack)
4747 # +unknown+ (un-packaged, un-cloned)
48- def to_s
48+ #
49+ # @param [Boolean] human_readable whether the output should be human readable or machine readable
50+ # @return [String] a +String+ representation of the version
51+ def to_s ( human_readable = true )
4952 s = [ ]
5053 s << @version if @version
51- s << '(offline)' if @offline
52- s << '|' if @version
54+ s << ( human_readable ? '(offline)' : 'offline' ) if @offline
55+ s << '|' if @version && human_readable
5356 s << "#{ @remote } ##{ @hash } " if @remote && @hash
5457 s << 'unknown' if s . empty?
5558
56- s . join ' '
59+ s . join ( human_readable ? ' ' : '-' )
5760 end
5861
5962 private
Original file line number Diff line number Diff line change 3535 'remote' => 'test-remote' , 'version' => 'test-version' } do
3636
3737 expect ( buildpack_version . to_s ) . to match ( /test-version (offline) | test-remote#test-hash/ )
38+ expect ( buildpack_version . to_s ( false ) ) . to match ( /test-version-offline-test-remote#test-hash/ )
3839 expect ( stderr . string ) . to match ( /test-version (offline) | test-remote#test-hash/ )
3940 end
4041
4445 'remote' => 'test-remote' , 'version' => 'test-version' } do
4546
4647 expect ( buildpack_version . to_s ) . to match ( /test-version | test-remote#test-hash/ )
48+ expect ( buildpack_version . to_s ( false ) ) . to match ( /test-version-test-remote#test-hash/ )
4749 expect ( stderr . string ) . to match ( /test-version | test-remote#test-hash/ )
4850 end
4951
6365 . and_return ( 'test-remote' )
6466
6567 expect ( buildpack_version . to_s ) . to match ( /test-remote#test-hash/ )
68+ expect ( buildpack_version . to_s ( false ) ) . to match ( /test-remote#test-hash/ )
6669 expect ( stderr . string ) . to match ( /test-remote#test-hash/ )
6770 end
6871
7275 allow_any_instance_of ( described_class ) . to receive ( :system ) . with ( 'which git > /dev/null' ) . and_return ( false )
7376
7477 expect ( buildpack_version . to_s ) . to match ( /unknown/ )
78+ expect ( buildpack_version . to_s ( false ) ) . to match ( /unknown/ )
7579 expect ( stderr . string ) . to match ( /unknown/ )
7680 end
7781
You can’t perform that action at this time.
0 commit comments