4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/gitjira/setup.rb', line 4
def self.init(force = false)
if self.setup? and not force
STDERR.puts "Repository is configured. Overwrite with:"
STDERR.puts "\t$ git-jira init -f # or git-jira init --force."
return 1
end
host = username = password = projectkey= nil
host = ask("JIRA host (e.g. https://jira.example.org): ")
host = "#{host}/" if not host.empty? and not host.end_with?("/")
username = ask("Your JIRA username : ")
password = ask("Your JIRA password : "){ |q| q.echo = "*" }
base64 = Base64.strict_encode64("#{username}:#{password}")
username = password = nil
projectkey = ask("Related JIRA project key (e.g. PROJ) : ")
if not host.empty? and not projectkey.empty?
`git config --local gitjira.host #{host}`
`git config --local gitjira.credentials #{base64.to_s}`
`git config --local gitjira.projectkey #{projectkey}`
return 0
else
STDERR.puts "[ERROR] Please fill out all needed fields."
return 1
end
end
|