Read about our upcoming Code of Conduct on this issue

Commit e8ffde87 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

lib/bitbucket: backported up to f155cc9034f2 from GitLab

This notably solves the username issue (#102)
by using nickname everywhere.

Did not include the filtering, would need to check the
consequences in app/ and notably views, but could be
done as a follow-up.

It should also be less memory-hungry thanks to the
freezing of litterals.


commit f155cc9034f2247c5d368f9b0212ad44248b0c5e
Author: GitLab Bot <gitlab-bot@gitlab.com>
Date:   Wed Oct 16 03:06:12 2019 +0000

    Add latest changes from gitlab-org/gitlab@master

commit e66d6781ef36e39d15b1b9bc84cc30e87969edad
Author: GitLab Bot <gitlab-bot@gitlab.com>
Date:   Thu Sep 26 18:06:29 2019 +0000

    Add latest changes from gitlab-org/gitlab@master

commit 736b5908da637cbb35eb5fd1a10790c2ee17fcde
Author: Dinesh Panda <dineshpanda92@gmail.com>
Date:   Tue Sep 10 08:11:43 2019 +0000

    Avoid calling freeze on already frozen strings in lib

commit 5ba77a49997221cc646f158d56c86a636b42e735
Author: George Koltsov <gkoltsov@gitlab.com>
Date:   Wed Aug 7 14:01:18 2019 +0100

    Add author lines to project import comments

commit d598e4fd937797a7f7778f5b4158ebf73139ce7f
Author: gfyoung <gfyoung17@gmail.com>
Date:   Sat Oct 6 16:10:08 2018 -0700

    Enable more frozen string in lib/**/*.rb

    Enables frozen for the following:

    * lib/*.rb
    * lib/banzai/**/*.rb
    * lib/bitbucket/**/*.rb
    * lib/constraints/**/*.rb
    * lib/container_registry/**/*.rb
    * lib/declarative_policy/**/*.rb

    Partially addresses #47424.

--HG--
branch : heptapod-0-6-stable
parent beaee2685b08
# frozen_string_literal: true
module Bitbucket
class Client
attr_reader :connection
......
# frozen_string_literal: true
module Bitbucket
class Collection < Enumerator
def initialize(paginator)
......
# frozen_string_literal: true
module Bitbucket
class Connection
DEFAULT_API_VERSION = '2.0'.freeze
DEFAULT_BASE_URI = 'https://api.bitbucket.org/'.freeze
DEFAULT_API_VERSION = '2.0'
DEFAULT_BASE_URI = 'https://api.bitbucket.org/'
DEFAULT_QUERY = {}.freeze
attr_reader :expires_at, :expires_in, :refresh_token, :token
......
# frozen_string_literal: true
module Bitbucket
module Error
Unauthorized = Class.new(StandardError)
......
# frozen_string_literal: true
module Bitbucket
class Page
attr_reader :attrs, :items
......@@ -28,7 +30,7 @@ def parse_values(raw, bitbucket_rep_class)
end
def representation_class(type)
Bitbucket::Representation.const_get(type.to_s.camelize)
Bitbucket::Representation.const_get(type.to_s.camelize, false)
end
end
end
# frozen_string_literal: true
module Bitbucket
class Paginator
PAGE_LENGTH = 50 # The minimum length is 10 and the maximum is 100.
......
# frozen_string_literal: true
module Bitbucket
module Representation
class Base
......
# frozen_string_literal: true
module Bitbucket
module Representation
class Comment < Representation::Base
def author
user['username']
user['nickname']
end
def note
......
# frozen_string_literal: true
module Bitbucket
module Representation
class Issue < Representation::Base
......@@ -12,7 +14,7 @@ def kind
end
def author
raw.dig('reporter', 'username')
raw.dig('reporter', 'nickname')
end
def description
......
# frozen_string_literal: true
module Bitbucket
module Representation
class PullRequest < Representation::Base
def author
raw.fetch('author', {}).fetch('username', nil)
raw.fetch('author', {}).fetch('nickname', nil)
end
def description
......
# frozen_string_literal: true
module Bitbucket
module Representation
class PullRequestComment < Comment
......
# frozen_string_literal: true
module Bitbucket
module Representation
class Repo < Representation::Base
......
# frozen_string_literal: true
module Bitbucket
module Representation
class User < Representation::Base
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment