Class: CommitLive::Submit::GitHelper
- Inherits:
-
Object
- Object
- CommitLive::Submit::GitHelper
- Defined in:
- lib/commit-live/lesson/git-helper.rb
Constant Summary collapse
- HOME_DIR =
File.("~")
- REPO_BELONGS_TO_US =
[ 'commit-live-students' ]
Instance Attribute Summary collapse
-
#currentLesson ⇒ Object
readonly
Returns the value of attribute currentLesson.
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#lessonName ⇒ Object
readonly
Returns the value of attribute lessonName.
-
#netrc ⇒ Object
readonly
Returns the value of attribute netrc.
-
#remote_name ⇒ Object
Returns the value of attribute remote_name.
-
#rootDir ⇒ Object
readonly
Returns the value of attribute rootDir.
-
#sentry ⇒ Object
readonly
Returns the value of attribute sentry.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#track_slug ⇒ Object
readonly
Returns the value of attribute track_slug.
Instance Method Summary collapse
- #commitAndPush ⇒ Object
-
#initialize(trackSlug) ⇒ GitHelper
constructor
A new instance of GitHelper.
Constructor Details
#initialize(trackSlug) ⇒ GitHelper
Returns a new instance of GitHelper.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/commit-live/lesson/git-helper.rb', line 18 def initialize(trackSlug) @track_slug = trackSlug @git = setGit @netrc = CommitLive::NetrcInteractor.new() @currentLesson = CommitLive::Current.new @status = CommitLive::Status.new @lessonName = repo_name(remote: 'origin') @sentry = CommitLive::Sentry.new() if File.exists?("#{HOME_DIR}/.ga-config") @rootDir = YAML.load(File.read("#{HOME_DIR}/.ga-config"))[:workspace] end end |
Instance Attribute Details
#currentLesson ⇒ Object (readonly)
Returns the value of attribute currentLesson.
10 11 12 |
# File 'lib/commit-live/lesson/git-helper.rb', line 10 def currentLesson @currentLesson end |
#git ⇒ Object (readonly)
Returns the value of attribute git.
10 11 12 |
# File 'lib/commit-live/lesson/git-helper.rb', line 10 def git @git end |
#lessonName ⇒ Object (readonly)
Returns the value of attribute lessonName.
10 11 12 |
# File 'lib/commit-live/lesson/git-helper.rb', line 10 def lessonName @lessonName end |
#netrc ⇒ Object (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_name ⇒ Object
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 |
#rootDir ⇒ Object (readonly)
Returns the value of attribute rootDir.
10 11 12 |
# File 'lib/commit-live/lesson/git-helper.rb', line 10 def rootDir @rootDir end |
#sentry ⇒ Object (readonly)
Returns the value of attribute sentry.
10 11 12 |
# File 'lib/commit-live/lesson/git-helper.rb', line 10 def sentry @sentry end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/commit-live/lesson/git-helper.rb', line 10 def status @status end |
#track_slug ⇒ Object (readonly)
Returns the value of attribute track_slug.
10 11 12 |
# File 'lib/commit-live/lesson/git-helper.rb', line 10 def track_slug @track_slug end |
Instance Method Details
#commitAndPush ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/commit-live/lesson/git-helper.rb', line 31 def commitAndPush checkRemote check_if_practice_lesson check_if_user_in_right_folder # Check if User passed test cases if is_test_case_passed # Push to User's Github addChanges commitChanges push if !is_submitted_pr # 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 |