Class: CommitLive::Submit::GitHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/commit-live/lesson/git-helper.rb

Constant Summary collapse

REPO_BELONGS_TO_US =
[
  'commit-live-students'
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGitHelper

Returns a new instance of GitHelper.



17
18
19
20
21
22
23
24
# File 'lib/commit-live/lesson/git-helper.rb', line 17

def initialize()
  @git = setGit
  @netrc = CommitLive::NetrcInteractor.new()
  @currentLesson = CommitLive::Current.new
  @status = CommitLive::Status.new
  @lessonName = repo_name(remote: 'origin')
  @sentry = CommitLive::Sentry.new()
end

Instance Attribute Details

#currentLessonObject (readonly)

Returns the value of attribute currentLesson.



10
11
12
# File 'lib/commit-live/lesson/git-helper.rb', line 10

def currentLesson
  @currentLesson
end

#gitObject (readonly)

Returns the value of attribute git.



10
11
12
# File 'lib/commit-live/lesson/git-helper.rb', line 10

def git
  @git
end

#lessonNameObject (readonly)

Returns the value of attribute lessonName.



10
11
12
# File 'lib/commit-live/lesson/git-helper.rb', line 10

def lessonName
  @lessonName
end

#netrcObject (readonly)

Returns the value of attribute netrc.



10
11
12
# File 'lib/commit-live/lesson/git-helper.rb', line 10

def netrc
  @netrc
end

#remote_nameObject

Returns the value of attribute remote_name.



11
12
13
# File 'lib/commit-live/lesson/git-helper.rb', line 11

def remote_name
  @remote_name
end

#sentryObject (readonly)

Returns the value of attribute sentry.



10
11
12
# File 'lib/commit-live/lesson/git-helper.rb', line 10

def sentry
  @sentry
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/commit-live/lesson/git-helper.rb', line 10

def status
  @status
end

Instance Method Details

#commitAndPushObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/commit-live/lesson/git-helper.rb', line 26

def commitAndPush
  checkRemote

  check_if_practice_lesson

  testCasePassed = currentLesson.getValue('test_case_pass')
  # Check if User passed test cases
  if testCasePassed
    # Push to User's Github
    addChanges
    commitChanges
    push

    pullRequestSubmitted = currentLesson.getValue('submitted_pull_request')
    if !pullRequestSubmitted
      # Create Pull Request
      createPullRequest
      update_lesson_status
    end

    puts "Done."
  else
    puts "It seems you have not passed all the test cases."
    puts "Please execute `clive test` before submitting your code!"
    exit
  end
end