Class: GitPusshuTen::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/gitpusshuten/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pushingObject Also known as: pushing?

Pushing a boolean that determines whether git is currently busy pushing



13
14
15
# File 'lib/gitpusshuten/git.rb', line 13

def pushing
  @pushing
end

#typeObject

Push-To Chain “type” represents either “tag”, “branch” or “ref” “value” represents the value of the “type”



8
9
10
# File 'lib/gitpusshuten/git.rb', line 8

def type
  @type
end

#valueObject

Push-To Chain “type” represents either “tag”, “branch” or “ref” “value” represents the value of the “type”



8
9
10
# File 'lib/gitpusshuten/git.rb', line 8

def value
  @value
end

Instance Method Details

#add_remote(remote, url) ⇒ Object

Adds the specified remote with the specified url to the git repository



24
25
26
# File 'lib/gitpusshuten/git.rb', line 24

def add_remote(remote, url)
  git("remote add #{remote} #{url}")
end

#has_remote?(remote) ⇒ Boolean

Determines whether the repository has the specified remote defined

Returns:

  • (Boolean)


18
19
20
# File 'lib/gitpusshuten/git.rb', line 18

def has_remote?(remote)
  git('remote') =~ /#{remote}/
end

#ignore!Object

Adds ignore line to the gitignore.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/gitpusshuten/git.rb', line 48

def ignore!
  if File.exist?('.gitignore')
    if not File.read('.gitignore').include?('.gitpusshuten/**/*')
      File.open('.gitignore', 'a') do |file|
        file << "\n.gitpusshuten/**/*"
      end
    end
  else
    %x[echo ".gitpusshuten/**/*" >> .gitignore]
  end
end

#initialize!Object

Initializes Git



42
43
44
# File 'lib/gitpusshuten/git.rb', line 42

def initialize!
  %x[git init]
end

#initialized?Boolean

Determines whether Git has been initialized

Returns:

  • (Boolean)


36
37
38
# File 'lib/gitpusshuten/git.rb', line 36

def initialized?
  File.directory?(File.join(Dir.pwd, '.git'))
end

#push(type, value) ⇒ Object

Push Begin of the push(type, value).to(remote) chain Pass in the type (“tag”, “branch” or “ref”) as the first argument followed by the value of the type (e.g. “1.4.2”, “develop”, or “9fb5c3201186”)



65
66
67
68
69
# File 'lib/gitpusshuten/git.rb', line 65

def push(type, value)
  @type  = type
  @value = value
  self
end

#remove_remote(remote) ⇒ Object

Removes the specified remote from the git repository



30
31
32
# File 'lib/gitpusshuten/git.rb', line 30

def remove_remote(remote)
  git("remote rm #{remote}")
end

#to(remote) ⇒ Object

To End of the push(type, value).to(remote) chain Pass in the remote (e.g. “staging”) as the first argument



75
76
77
78
79
80
81
# File 'lib/gitpusshuten/git.rb', line 75

def to(remote)
  @pushing = true
  send("push_#{type}", value, remote)
  @pushing = false
  @type    = nil
  @value   = nil
end