Module: Asgit

Defined in:
lib/asgit.rb,
lib/asgit/url.rb,
lib/asgit/shell.rb,
lib/asgit/project.rb,
lib/asgit/version.rb,
lib/asgit/services.rb,
lib/asgit/services/github.rb,
lib/asgit/services/service.rb,
lib/asgit/services/bitbucket.rb

Defined Under Namespace

Modules: Services, Shell Classes: Project, Url

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.current_branchString

Get current git branch based on exec directory

Returns:

  • (String)

    the current checked out branch



19
20
21
22
23
# File 'lib/asgit.rb', line 19

def current_branch
  Shell.run "git symbolic-ref HEAD --short" do |output|
    return output.strip
  end
end

.current_commitString

Get current git commit based on exec directory

Returns:

  • (String)

    the current commit level



27
28
29
30
31
# File 'lib/asgit.rb', line 27

def current_commit
  Shell.run "git rev-parse HEAD" do |output|
    return output.strip
  end
end

.remote_up_to_date?Boolean

Check if branch is in sync with remote

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/asgit.rb', line 35

def remote_up_to_date?
  status, stdout, stderr = Shell.run "git push --dry-run --porcelain"
  return status && stdout.match(/#{current_branch}\s+?\[up\sto\sdate\]/)
end

.working_tree_clean?Boolean

Check if working tree is clean

Returns:

  • (Boolean)

    true if branch is clean



11
12
13
14
15
# File 'lib/asgit.rb', line 11

def working_tree_clean?
  Shell.run "git status --porcelain" do |output|
    return output.empty?
  end
end