Sha256: 501bb0645fc2451f864c2eeff66e281d8c776be948a7c0f179655d1da0517be5

Contents?: true

Size: 1.79 KB

Versions: 6

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

# tau git lib
module GitLib
  # Pull git workspace.
  def git_lib_pull_workspace
    log.info 'Pulling git workspace'

    _git_lib_git_pull_origin_hg
  end

  # Push git workspace.
  def git_lib_push_workspace(message)
    log.info 'Pushing git workspace'

    return false unless _git_lib_git_add_all
    return false unless _git_lib_git_commit message
    return false unless _git_lib_git_pull_origin_hg

    _git_lib_git_push_origin_hg
  end

  private

  # git add all.
  def _git_lib_git_add_all
    log.debug 'Adding all files to git'

    cmd_git_add_all = config.active['cmd_git_lib_git_add_all']

    return true if try cmd_git_add_all

    log.error 'Unable to add all files to git'
    false
  end

  # git commit.
  def _git_lib_git_commit(message)
    log.debug "Committing to git with message \"#{message}\""

    cmd_git_commit = format(
      config.active['cmd_git_lib_git_commit'],
      message: message
    )

    return true if try cmd_git_commit

    log.error 'Unable to commit to git'
    false
  end

  # git pull origin hg.
  def _git_lib_git_pull_origin_hg
    log.info 'Pulling git hg branch from origin'
    cmd_git_lib_git_pull_origin = format(
      config.active['cmd_git_lib_git_pull_origin'],
      main: config.active['git_hg_branch']
    )

    return true if (try cmd_git_lib_git_pull_origin).exitstatus.zero?

    log.error 'Unable to pull git hg branch'
    false
  end

  # git push origin hg.
  def _git_lib_git_push_origin_hg
    log.debug 'Pushing git hg branch to origin'

    cmd_git_lib_git_push_origin = format(
      config.active['cmd_git_lib_git_push_origin'],
      main: config.active['git_hg_branch']
    )

    return true if (try cmd_git_lib_git_push_origin).exitstatus.zero?

    log.error 'Unable to push git hg branch'
    false
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
takeltau-0.36.1 lib/takeltau/git/lib.rb
takeltau-0.35.18 lib/takeltau/git/lib.rb
takeltau-0.35.15 lib/takeltau/git/lib.rb
takeltau-0.35.14 lib/takeltau/git/lib.rb
takeltau-0.35.12 lib/takeltau/git/lib.rb
takeltau-0.35.11 lib/takeltau/git/lib.rb