Class Git::Branch
In: lib/git/branch.rb
Parent: Path

Methods

archive   checkout   create   current   delete   gcommit   in_branch   merge   new   to_a   to_s   update_ref  

Attributes

full  [RW] 
name  [RW] 
remote  [RW] 

Public Class methods

[Source]

# File lib/git/branch.rb, line 9
    def initialize(base, name)
      @remote = nil
      @full = name
      @base = base
      
      parts = name.split('/')
      if parts[1]
        @remote = Git::Remote.new(@base, parts[0])
        @name = parts[1]
      else
        @name = parts[0]
      end
    end

Public Instance methods

[Source]

# File lib/git/branch.rb, line 33
    def archive(file, opts = {})
      @base.lib.archive(@full, file, opts)
    end

[Source]

# File lib/git/branch.rb, line 28
    def checkout
      check_if_create
      @base.checkout(@full)
    end

[Source]

# File lib/git/branch.rb, line 53
    def create
      check_if_create
    end

[Source]

# File lib/git/branch.rb, line 61
    def current
      determine_current
    end

[Source]

# File lib/git/branch.rb, line 57
    def delete
      @base.lib.branch_delete(@name)
    end

[Source]

# File lib/git/branch.rb, line 23
    def gcommit
      @gcommit = @base.gcommit(@full) if !@gcommit
      @gcommit
    end

g.branch(‘new_branch’).in_branch do

  # create new file
  # do other stuff
  return true # auto commits and switches back

end

[Source]

# File lib/git/branch.rb, line 42
    def in_branch (message = 'in branch work')
      old_current = @base.lib.branch_current
      checkout
      if yield
        @base.commit_all(message)
      else
        @base.reset_hard
      end
      @base.checkout(old_current)
    end

[Source]

# File lib/git/branch.rb, line 65
    def merge(branch = nil, message = nil)
      if branch
        in_branch do 
          @base.merge(branch, message)
          false
        end
        # merge a branch into this one
      else
        # merge this branch into the current one
        @base.merge(@name)
      end
    end

[Source]

# File lib/git/branch.rb, line 82
    def to_a
      [@full]
    end

[Source]

# File lib/git/branch.rb, line 86
    def to_s
      @full
    end

[Source]

# File lib/git/branch.rb, line 78
    def update_ref(commit)
      @base.lib.update_ref(@full, commit)
    end

[Validate]