Class: ProjectRepoSync

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, repo) ⇒ ProjectRepoSync

Returns a new instance of ProjectRepoSync.



8
9
10
11
12
# File 'lib/project_repo_sync.rb', line 8

def initialize(user, repo)
  @client = ClientResolver.client
  @user = user
  @repo = repo
end

Instance Attribute Details

#repoObject (readonly)

Returns the value of attribute repo.



2
3
4
# File 'lib/project_repo_sync.rb', line 2

def repo
  @repo
end

#userObject (readonly)

Returns the value of attribute user.



2
3
4
# File 'lib/project_repo_sync.rb', line 2

def user
  @user
end

Class Method Details

.git_checkout(branch) ⇒ Object



4
5
6
# File 'lib/project_repo_sync.rb', line 4

def self.git_checkout(branch)
  ->(){ "git checkout #{branch}" }
end

Instance Method Details

#sync_assignment_branchesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/project_repo_sync.rb', line 14

def sync_assignment_branches
  pull_details = PullBranchLister.new(@user, @repo).list

  %x(git checkout -f master | git branch | grep -v "^..master$" | sed 's/^[ *]*//' | sed 's/^/git branch -D /' | bash)

  git_commands = pull_details.map &git_command_orgnaizer()
  git_commands.flatten.each do |command|
    prepared_command = command.call
    puts "EXEC #{prepared_command}" if @logging
    `#{prepared_command}`
    puts "\n" if @logging
  end
end