Files
chromebrew/packages/git_prompt.rb
Maximilian Downey Twiss de24923ee8 Add Rubocop CI (#7083)
* Rename IgnoredPatterns to AllowedPatterns.

* Exclude docopt.rb (not our code) from Rubocop

* Disable Style/RedundantReturn

* Disable Style/MutableConstant

* Disable Style/NumericLiterals

* Set Layout/IndentationStyle to spaces

* Temporarily disable various cops.

* Add Rubocop CI via Octocop

* Lint tree with rubocop -A -c .rubocop.yml

Co-authored-by: Satadru Pramanik <satadru@gmail.com>
2022-08-22 13:31:25 -04:00

39 lines
1.3 KiB
Ruby

require 'package'
class Git_prompt < Package
description 'Display the git branch and status in the command prompt'
homepage 'https://github.com/git/git'
version '2.32.0'
license 'GPL-2'
compatibility 'all'
source_url 'SKIP'
def self.build
system "curl -#LO https://raw.githubusercontent.com/git/git/v#{version}/contrib/completion/git-prompt.sh"
abort 'Checksum mismatch. :/ Try again.'.lightred unless Digest::SHA256.hexdigest(File.read('git-prompt.sh')) == '1fbced3fe345ec14f828ffb876e191d69457cccc807c70f54c9ba48cb2a6620e'
git_env = <<~EOF
GIT_PS1_SHOWDIRTYSTATE=yes
GIT_PS1_SHOWSTASHSTATE=yes
GIT_PS1_SHOWUNTRACKEDFILES=yes
GIT_PS1_SHOWUPSTREAM=auto
GIT_PS1_DESCRIBE_STYLE=default
GIT_PS1_SHOWCOLORHINTS=yes
PS1='\\[\\033[1;34m\\]\\u@\\h \\[\\033[1;33m\\]\\w \\[\\033[1;31m\\]$(__git_ps1 "(%s)")\\[\\033[0m\\]\\$ '
EOF
File.write('git-prompt.sh', git_env, mode: 'a')
end
def self.install
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/etc/bash.d"
FileUtils.install 'git-prompt.sh', "#{CREW_DEST_PREFIX}/etc/bash.d/git-prompt.sh", mode: 0o644
end
def self.postinstall
puts "\nTo finish the installation, execute the following:".lightblue
puts 'source ~/.bashrc'.lightblue
puts "\ncd /path/to/git/repo and you should see the branch displayed in the prompt\n".lightblue
end
end