Class List Method List File List

# Class: GitUpdater

Inherits:
  Updater
  - Object
  - Updater
  - GitUpdater
  show all
Defined in:
  lib/common/updater/git_updater.rb

## Instance Attribute Summary

### Attributes inherited from Updater

#repo_directory

## Instance Method Summary (collapse)

- - (Boolean) has_local_changes?
- - (Boolean) is_installed?
- - (Object) local_revision_number

  Git has not a revsion number like SVN, so we will take the 7 first chars of the last commit hash.

- - (Object) repo_directory_arguments protected
- - (Object) reset_head
- - (Object) update

### Methods inherited from Updater

#initialize

## Constructor Details

This class inherits a constructor from Updater

## Instance Method Details

### - (`Boolean`) has_local_changes?

Returns:

- (`Boolean`)

    22
    23
    24
    # File 'lib/common/updater/git_updater.rb', line 22

    def has_local_changes?
      %x[git #{repo_directory_arguments()} diff --exit-code 2>&1] =~ /diff/ ? true : false
    end

### - (`Boolean`) is_installed?

Returns:

- (`Boolean`)

    7
    8
    9
    # File 'lib/common/updater/git_updater.rb', line 7

    def is_installed?
      %x[git #{repo_directory_arguments()} status 2>&1] =~ /On branch/ ? true : false
    end

### - (`Object`) local_revision_number

Git has not a revsion number like SVN, so we will take the 7 first chars of the last commit hash

    13
    14
    15
    16
    # File 'lib/common/updater/git_updater.rb', line 13

    def local_revision_number
      git_log = %x[git #{repo_directory_arguments()} log -1 2>&1]
      git_log[/commit ([0-9a-z]{7})/i, 1].to_s
    end

### - (`Object`) repo_directory_arguments (protected)

    31
    32
    33
    34
    35
    # File 'lib/common/updater/git_updater.rb', line 31

    def repo_directory_arguments
      if @repo_directory
        return "--git-dir=\"#{@repo_directory}/.git\" --work-tree=\"#{@repo_directory}\""
      end
    end

### - (`Object`) reset_head

    26
    27
    28
    # File 'lib/common/updater/git_updater.rb', line 26

    def reset_head
      %x[git #{repo_directory_arguments()} reset --hard HEAD]
    end

### - (`Object`) update

    18
    19
    20
    # File 'lib/common/updater/git_updater.rb', line 18

    def update
      %x[git #{repo_directory_arguments()} pull]
    end