Class: Ruuuby::MetaData::GitAPI
- Inherits:
-
RuuubyAPIComponentCLI
- Object
- RuuubyEngineComponent
- RuuubyAPIComponent
- RuuubyAPIComponentCLI
- Ruuuby::MetaData::GitAPI
- Defined in:
- lib/ruuuby/ruuuby/api/api_git.rb
Overview
helpful CLI commands:
---------------------------------------------------------------------------------------------------------
| scenario | {reference) command/template |
| -------------------------------------------------- | ------------------------------------------------ |
| human readable view of staging | `git diff --cached --stat` |
| human readable view of commits | `git log --pretty=format:"%H|%ad|%s" --date=iso` |
| human readable view of current configs applied | `git config --list --show-origin --show-scope` |
| for script: get num files w/ diffs | `git diff --cached --numstat | wc -l` |
| alternative for `git status` | `git status --porcelain=v2 -b` |
| clone only latest data, save time & network-data | `git clone --depth 1 <git_url>` |
| check for any fixable text/file/syntax issues | `git diff --cached --check` |
| check if file is tracked (not tracked if no output) | `git ls-files <path_name>` |
---------------------------------------------------------------------------------------------------------
helpful resources
| scenario(s) | resource | reference_id | | —————————— | —————————————————————————————- | ———— | | list of relating git functions | github.com/libgit2/libgit2sharp/wiki/LibGit2Sharp-Hitchhiker’s-Guide-to-Git | 0x0 | | base gem documentation | github.com/libgit2/rugged | 0x1 | | provides version list overview | en.wikipedia.org/wiki/Git | 0x2 | | tips n tricks | community.lsst.org/t/git-tips-and-tricks/3169/2 | 0x3 | | useful settings esp. w/ MacOS | gist.github.com/trey/2722934 | 0x4 | | (not utilized/tested yet) | gist.github.com/brandonsimpson/54d9e085c9fde5e6ad3a | 0x5 | | turning off status hints | stackoverflow.com/questions/55463863/how-to-turn-off-the-help-hints-in-git-output | 0x6 | | TODO: look into | github.com/so-fancy/diff-so-fancy | | | TODO: look into | git-scm.com/book/en/v2/Appendix-B%3A-Embedding-Git-in-your-Applications-Libgit2 | | | TODO: look into | git-scm.com/book/en/v2/Customizing-Git-Git-Hooks | |
terminology:
- repository:
misc notes:
‘💎.engine.api_locale.api_git`
Instance Attribute Summary collapse
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Attributes inherited from RuuubyAPIComponentCLI
Attributes inherited from RuuubyEngineComponent
Instance Method Summary collapse
- #branch_names ⇒ Array
- #configs ⇒ Rugged::Config
-
#fetch_commits_until(stop_sha) ⇒ Array
TODO: NEEDS TDD!!!.
- #healthy?(perform_full_check = false) ⇒ Boolean
- #healthy_repo? ⇒ Boolean
-
#initialize(engine) ⇒ GitAPI
constructor
A new instance of GitAPI.
- #last_commit ⇒ Rugged::Commit
- #release_tags ⇒ Array
- #remote_release_current ⇒ Array
- #remote_release_previous ⇒ Array
- #version_libgit2 ⇒ Array
- #∃attribute?(attribute_key, expected_key_val_pairs) ⇒ Boolean
-
#∃commit?(sha) ⇒ Boolean
True, if the SHA was found as an existing GIT Commit.
-
#∃fixable_syntax_errors? ⇒ Boolean
‘💎.engine.api_locale.api_git.∃fixable_syntax_errors?`.
-
#∃index_conflicts? ⇒ Boolean
‘💎.engine.api_locale.api_git.∃index_conflicts?`.
Methods inherited from RuuubyAPIComponentCLI
#_calculate_version, #executed_cmd_returned_expected_output, #run_cmd, #run_cmd_raw
Methods inherited from RuuubyAPIComponent
Methods inherited from RuuubyEngineComponent
Constructor Details
#initialize(engine) ⇒ GitAPI
Returns a new instance of GitAPI.
70 71 72 73 74 75 76 77 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 70 def initialize(engine) super(engine, 'git') @repo = ::Rugged::Repository.new(@engine.path_base) # cached fields @index = @repo.index @branch_names = [] = [] end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
68 69 70 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 68 def repo @repo end |
Instance Method Details
#branch_names ⇒ Array
227 228 229 230 231 232 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 227 def branch_names if @branch_names. |
#configs ⇒ Rugged::Config
83 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 83 def configs; @repo.config; end |
#fetch_commits_until(stop_sha) ⇒ Array
TODO: NEEDS TDD!!!
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 132 def fetch_commits_until(stop_sha) if self. |
#healthy?(perform_full_check = false) ⇒ Boolean
182 183 184 185 186 187 188 189 190 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 182 def healthy?(perform_full_check=false) |
#healthy_repo? ⇒ Boolean
193 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 193 def healthy_repo?; (!@repo.) && (!@repo.empty?) && (!@repo.head_unborn?) && (!@repo.head_detached?) && (!@repo.shallow?); end |
#last_commit ⇒ Rugged::Commit
80 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 80 def last_commit; @repo.last_commit; end |
#release_tags ⇒ Array
212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 212 def if . |
#remote_release_current ⇒ Array
154 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 154 def remote_release_current; self.[0]; end |
#remote_release_previous ⇒ Array
157 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 157 def remote_release_previous; self.[1]; end |
#version_libgit2 ⇒ Array
160 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 160 def version_libgit2; ::Rugged.libgit2_version; end |
#∃attribute?(attribute_key, expected_key_val_pairs) ⇒ Boolean
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 91 def |
#∃commit?(sha) ⇒ Boolean
Returns true, if the SHA was found as an existing GIT Commit.
116 117 118 119 120 121 122 123 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 116 def |
#∃fixable_syntax_errors? ⇒ Boolean
‘💎.engine.api_locale.api_git.∃fixable_syntax_errors?`
203 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 203 def |
#∃index_conflicts? ⇒ Boolean
‘💎.engine.api_locale.api_git.∃index_conflicts?`
198 |
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 198 def |