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
- REMOTE_ORIGIN_REGEX =
For simplicity, we match any character except the ones the separators.
%r{ \A (?:https://(.+?)/|git@(.+?):) ([^/]+/.*?) (?:\.git)? \Z }x
- ORIGIN_NAME =
'origin'- UPSTREAM_NAME =
'upstream'
Instance Method Summary collapse
- #abstract_issues(milestone: nil) ⇒ Object
-
#authenticated_user ⇒ Object
REMOTE FUNCTIONALITIES (ACCOUNT).
-
#collaborators ⇒ Object
REMOTE FUNCTIONALITIES (REPOSITORY).
- #create_gist(filename, content, description: nil, publik: false) ⇒ Object
- #create_issue(title, description) ⇒ Object
- #create_pr(title, description, head) ⇒ Object
-
#current_branch ⇒ Object
OTHER/CONVENIENCE FUNCTIONALITIES.
-
#initialize(api_token, upstream: false, location: nil) ⇒ Repository
constructor
A new instance of Repository.
- #issues ⇒ Object
- #labels ⇒ Object
- #milestone(number) ⇒ Object
- #milestones ⇒ Object
- #prs(head: nil) ⇒ Object
Constructor Details
#initialize(api_token, upstream: false, location: nil) ⇒ Repository
Returns a new instance of Repository.
22 23 24 25 26 |
# File 'lib/geet/git/repository.rb', line 22 def initialize(api_token, upstream: false, location: nil) @api_token = api_token @upstream = upstream @location = location end |
Instance Method Details
#abstract_issues(milestone: nil) ⇒ Object
46 47 48 |
# File 'lib/geet/git/repository.rb', line 46 def abstract_issues(milestone: nil) provider_module::AbstractIssue.list(api_interface, milestone: milestone) end |
#authenticated_user ⇒ Object
REMOTE FUNCTIONALITIES (ACCOUNT)
72 73 74 |
# File 'lib/geet/git/repository.rb', line 72 def authenticated_user provider_module::Account.new(api_interface).authenticated_user end |
#collaborators ⇒ Object
REMOTE FUNCTIONALITIES (REPOSITORY)
30 31 32 |
# File 'lib/geet/git/repository.rb', line 30 def collaborators provider_module::Collaborator.list(api_interface) end |
#create_gist(filename, content, description: nil, publik: false) ⇒ Object
38 39 40 |
# File 'lib/geet/git/repository.rb', line 38 def create_gist(filename, content, description: nil, publik: false) provider_module::Gist.create(filename, content, api_interface, description: description, publik: publik) end |
#create_issue(title, description) ⇒ Object
42 43 44 |
# File 'lib/geet/git/repository.rb', line 42 def create_issue(title, description) provider_module::Issue.create(title, description, api_interface) end |
#create_pr(title, description, head) ⇒ Object
62 63 64 |
# File 'lib/geet/git/repository.rb', line 62 def create_pr(title, description, head) provider_module::PR.create(title, description, head, api_interface) end |
#current_branch ⇒ Object
OTHER/CONVENIENCE FUNCTIONALITIES
78 79 80 81 82 83 84 85 |
# File 'lib/geet/git/repository.rb', line 78 def current_branch gitdir_option = "--git-dir #{@location.shellescape}/.git" if @location branch = `git #{gitdir_option} rev-parse --abbrev-ref HEAD`.strip raise "Couldn't find current branch" if branch == 'HEAD' branch end |
#issues ⇒ Object
50 51 52 |
# File 'lib/geet/git/repository.rb', line 50 def issues provider_module::Issue.list(api_interface) end |
#labels ⇒ Object
34 35 36 |
# File 'lib/geet/git/repository.rb', line 34 def labels provider_module::Label.list(api_interface) end |
#milestone(number) ⇒ Object
54 55 56 |
# File 'lib/geet/git/repository.rb', line 54 def milestone(number) provider_module::Milestone.find(number, api_interface) end |
#milestones ⇒ Object
58 59 60 |
# File 'lib/geet/git/repository.rb', line 58 def milestones provider_module::Milestone.list(api_interface) end |
#prs(head: nil) ⇒ Object
66 67 68 |
# File 'lib/geet/git/repository.rb', line 66 def prs(head: nil) provider_module::PR.list(api_interface, head: head) end |