Class: Ruuuby::MetaData::GitAPI

Inherits:
RuuubyAPIComponentCLI show all
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

Attributes inherited from RuuubyAPIComponentCLI

#cmd_start

Attributes inherited from RuuubyEngineComponent

#versionable

Instance Method Summary collapse

Methods inherited from RuuubyAPIComponentCLI

#_calculate_version, #executed_cmd_returned_expected_output, #run_cmd, #run_cmd_raw

Methods inherited from RuuubyAPIComponent

#version

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 = []
  @release_tags = []
end

Instance Attribute Details

#repoObject (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_namesArray

Returns:



227
228
229
230
231
232
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 227

def branch_names
  if @branch_names.

#configsRugged::Config

Returns:

  • (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!!!

Parameters:

Returns:

Raises:

  • (RuntimeError)


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

Returns:

  • (Boolean)


193
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 193

def healthy_repo?; (!@repo.bare?) && (!@repo.empty?) && (!@repo.head_unborn?) && (!@repo.head_detached?) && (!@repo.shallow?); end

#last_commitRugged::Commit

Returns:

  • (Rugged::Commit)


80
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 80

def last_commit; @repo.last_commit; end

#release_tagsArray

Returns:



212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 212

def release_tags
  if @release_tags.

#remote_release_currentArray

Returns:



154
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 154

def remote_release_current; self.release_tags[0]; end

#remote_release_previousArray

Returns:



157
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 157

def remote_release_previous; self.release_tags[1]; end

#version_libgit2Array

Returns:



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

Parameters:

  • attribute_key (String)
  • expected_key_val_pairs (Hash)

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


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.

Parameters:

  • sha (String)

    | the SHA to search for

Returns:

  • (Boolean)

    true, if the SHA was found as an existing GIT Commit

Raises:

  • (ArgumentError)

    if sha is not a String



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?`

Returns:

  • (Boolean)


203
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 203

def 

#∃index_conflicts?Boolean

‘💎.engine.api_locale.api_git.∃index_conflicts?`

Returns:

  • (Boolean)


198
# File 'lib/ruuuby/ruuuby/api/api_git.rb', line 198

def