Class: Geet::Git::Repository
- Inherits:
-
Object
- Object
- Geet::Git::Repository
- Defined in:
- lib/geet/git/repository.rb
Overview
This class represents, for convenience, both the local and the remote repository, but the remote code is separated in each provider module.
Constant Summary collapse
- LOCAL_ACTION_ON_UPSTREAM_REPOSITORY_MESSAGE =
"The action will be performed on a fork, but an upstream repository has been found!\n"- ACTION_ON_PROTECTED_REPOSITORY_MESSAGE =
"This action will be performed on a protected repository!\n"- DEFAULT_GIT_CLIENT =
Geet::Utils::GitClient.new
Instance Method Summary collapse
- #abstract_issues(milestone: nil) ⇒ Object
-
#authenticated_user ⇒ Object
REMOTE FUNCTIONALITIES (ACCOUNT).
-
#collaborators ⇒ Object
REMOTE FUNCTIONALITIES (REPOSITORY).
- #create_issue(title, description) ⇒ Object
- #create_label(name, color) ⇒ Object
- #create_pr(title, description, head) ⇒ Object
- #delete_branch(name) ⇒ Object
-
#initialize(upstream: false, git_client: DEFAULT_GIT_CLIENT, warnings: true, protected_repositories: []) ⇒ Repository
constructor
warnings: disable all the warnings.
- #issues(assignee: nil) ⇒ Object
- #labels ⇒ Object
- #milestone(number) ⇒ Object
- #milestones ⇒ Object
- #prs(head: nil) ⇒ Object
-
#upstream? ⇒ Boolean
OTHER/CONVENIENCE FUNCTIONALITIES.
Constructor Details
#initialize(upstream: false, git_client: DEFAULT_GIT_CLIENT, warnings: true, protected_repositories: []) ⇒ Repository
warnings: disable all the warnings. protected_repositories: warn when creating an issue/pr on this repositories (entry format:
`owner/repo`).
25 26 27 28 29 30 31 |
# File 'lib/geet/git/repository.rb', line 25 def initialize(upstream: false, git_client: DEFAULT_GIT_CLIENT, warnings: true, protected_repositories: []) @upstream = upstream @git_client = git_client @api_token = extract_env_api_token @warnings = warnings @protected_repositories = protected_repositories end |
Instance Method Details
#abstract_issues(milestone: nil) ⇒ Object
58 59 60 |
# File 'lib/geet/git/repository.rb', line 58 def abstract_issues(milestone: nil) attempt_provider_call(:AbstractIssue, :list, api_interface, milestone: milestone) end |
#authenticated_user ⇒ Object
REMOTE FUNCTIONALITIES (ACCOUNT)
87 88 89 |
# File 'lib/geet/git/repository.rb', line 87 def authenticated_user attempt_provider_call(:Account, :new, api_interface).authenticated_user end |
#collaborators ⇒ Object
REMOTE FUNCTIONALITIES (REPOSITORY)
35 36 37 |
# File 'lib/geet/git/repository.rb', line 35 def collaborators attempt_provider_call(:Collaborator, :list, api_interface) end |
#create_issue(title, description) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/geet/git/repository.rb', line 43 def create_issue(title, description) confirm(LOCAL_ACTION_ON_UPSTREAM_REPOSITORY_MESSAGE) if local_action_on_upstream_repository? && @warnings confirm(ACTION_ON_PROTECTED_REPOSITORY_MESSAGE) if action_on_protected_repository? && @warnings attempt_provider_call(:Issue, :create, title, description, api_interface) end |
#create_label(name, color) ⇒ Object
50 51 52 |
# File 'lib/geet/git/repository.rb', line 50 def create_label(name, color) attempt_provider_call(:Label, :create, name, color, api_interface) end |
#create_pr(title, description, head) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/geet/git/repository.rb', line 74 def create_pr(title, description, head) confirm(LOCAL_ACTION_ON_UPSTREAM_REPOSITORY_MESSAGE) if local_action_on_upstream_repository? && @warnings confirm(ACTION_ON_PROTECTED_REPOSITORY_MESSAGE) if action_on_protected_repository? && @warnings attempt_provider_call(:PR, :create, title, description, head, api_interface) end |
#delete_branch(name) ⇒ Object
54 55 56 |
# File 'lib/geet/git/repository.rb', line 54 def delete_branch(name) attempt_provider_call(:Branch, :delete, name, api_interface) end |
#issues(assignee: nil) ⇒ Object
62 63 64 |
# File 'lib/geet/git/repository.rb', line 62 def issues(assignee: nil) attempt_provider_call(:Issue, :list, api_interface, assignee: assignee) end |
#labels ⇒ Object
39 40 41 |
# File 'lib/geet/git/repository.rb', line 39 def labels attempt_provider_call(:Label, :list, api_interface) end |
#milestone(number) ⇒ Object
66 67 68 |
# File 'lib/geet/git/repository.rb', line 66 def milestone(number) attempt_provider_call(:Milestone, :find, number, api_interface) end |
#milestones ⇒ Object
70 71 72 |
# File 'lib/geet/git/repository.rb', line 70 def milestones attempt_provider_call(:Milestone, :list, api_interface) end |
#prs(head: nil) ⇒ Object
81 82 83 |
# File 'lib/geet/git/repository.rb', line 81 def prs(head: nil) attempt_provider_call(:PR, :list, api_interface, head: head) end |
#upstream? ⇒ Boolean
OTHER/CONVENIENCE FUNCTIONALITIES
93 94 95 |
# File 'lib/geet/git/repository.rb', line 93 def upstream? @upstream end |