From 96d49bf04ce77c975fe500f4d961e4a1ffed4c26 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 30 Dec 2012 14:43:00 +0200 Subject: Use sdoc to generate application code documentation --- doc/code/classes/Gitlab/API.html | 76 ++ doc/code/classes/Gitlab/APIHelpers.html | 703 ++++++++++++++++++ doc/code/classes/Gitlab/AppLogger.html | 173 +++++ doc/code/classes/Gitlab/Application.html | 76 ++ doc/code/classes/Gitlab/Auth.html | 315 ++++++++ doc/code/classes/Gitlab/Entities.html | 151 ++++ doc/code/classes/Gitlab/Entities/Hook.html | 76 ++ doc/code/classes/Gitlab/Entities/Issue.html | 76 ++ doc/code/classes/Gitlab/Entities/MRNote.html | 76 ++ doc/code/classes/Gitlab/Entities/MergeRequest.html | 76 ++ doc/code/classes/Gitlab/Entities/Milestone.html | 76 ++ doc/code/classes/Gitlab/Entities/Note.html | 76 ++ doc/code/classes/Gitlab/Entities/Project.html | 76 ++ .../classes/Gitlab/Entities/ProjectMember.html | 76 ++ .../classes/Gitlab/Entities/ProjectSnippet.html | 76 ++ doc/code/classes/Gitlab/Entities/RepoCommit.html | 76 ++ doc/code/classes/Gitlab/Entities/RepoObject.html | 76 ++ doc/code/classes/Gitlab/Entities/SSHKey.html | 76 ++ doc/code/classes/Gitlab/Entities/User.html | 76 ++ doc/code/classes/Gitlab/Entities/UserBasic.html | 76 ++ doc/code/classes/Gitlab/Entities/UserLogin.html | 76 ++ doc/code/classes/Gitlab/GitLogger.html | 173 +++++ doc/code/classes/Gitlab/GitStats.html | 506 +++++++++++++ doc/code/classes/Gitlab/Gitolite.html | 536 ++++++++++++++ doc/code/classes/Gitlab/Gitolite/AccessDenied.html | 76 ++ doc/code/classes/Gitlab/GitoliteConfig.html | 810 +++++++++++++++++++++ .../classes/Gitlab/GitoliteConfig/PullError.html | 76 ++ .../classes/Gitlab/GitoliteConfig/PushError.html | 76 ++ doc/code/classes/Gitlab/Graph.html | 88 +++ doc/code/classes/Gitlab/Graph/Commit.html | 337 +++++++++ doc/code/classes/Gitlab/Graph/JsonBuilder.html | 707 ++++++++++++++++++ doc/code/classes/Gitlab/InlineDiff.html | 299 ++++++++ doc/code/classes/Gitlab/Issues.html | 82 +++ doc/code/classes/Gitlab/Logger.html | 315 ++++++++ doc/code/classes/Gitlab/Markdown.html | 258 +++++++ doc/code/classes/Gitlab/MergeRequests.html | 82 +++ doc/code/classes/Gitlab/Milestones.html | 82 +++ doc/code/classes/Gitlab/Notes.html | 100 +++ doc/code/classes/Gitlab/ProjectMover.html | 290 ++++++++ .../Gitlab/ProjectMover/ProjectMoveError.html | 76 ++ doc/code/classes/Gitlab/Projects.html | 82 +++ doc/code/classes/Gitlab/Regex.html | 261 +++++++ doc/code/classes/Gitlab/Satellite.html | 102 +++ doc/code/classes/Gitlab/Satellite/Action.html | 305 ++++++++ .../classes/Gitlab/Satellite/EditFileAction.html | 284 ++++++++ doc/code/classes/Gitlab/Satellite/MergeAction.html | 274 +++++++ doc/code/classes/Gitlab/Satellite/Satellite.html | 506 +++++++++++++ doc/code/classes/Gitlab/Seeder.html | 134 ++++ doc/code/classes/Gitlab/Session.html | 82 +++ doc/code/classes/Gitlab/Theme.html | 141 ++++ doc/code/classes/Gitlab/Users.html | 82 +++ 51 files changed, 9856 insertions(+) create mode 100644 doc/code/classes/Gitlab/API.html create mode 100644 doc/code/classes/Gitlab/APIHelpers.html create mode 100644 doc/code/classes/Gitlab/AppLogger.html create mode 100644 doc/code/classes/Gitlab/Application.html create mode 100644 doc/code/classes/Gitlab/Auth.html create mode 100644 doc/code/classes/Gitlab/Entities.html create mode 100644 doc/code/classes/Gitlab/Entities/Hook.html create mode 100644 doc/code/classes/Gitlab/Entities/Issue.html create mode 100644 doc/code/classes/Gitlab/Entities/MRNote.html create mode 100644 doc/code/classes/Gitlab/Entities/MergeRequest.html create mode 100644 doc/code/classes/Gitlab/Entities/Milestone.html create mode 100644 doc/code/classes/Gitlab/Entities/Note.html create mode 100644 doc/code/classes/Gitlab/Entities/Project.html create mode 100644 doc/code/classes/Gitlab/Entities/ProjectMember.html create mode 100644 doc/code/classes/Gitlab/Entities/ProjectSnippet.html create mode 100644 doc/code/classes/Gitlab/Entities/RepoCommit.html create mode 100644 doc/code/classes/Gitlab/Entities/RepoObject.html create mode 100644 doc/code/classes/Gitlab/Entities/SSHKey.html create mode 100644 doc/code/classes/Gitlab/Entities/User.html create mode 100644 doc/code/classes/Gitlab/Entities/UserBasic.html create mode 100644 doc/code/classes/Gitlab/Entities/UserLogin.html create mode 100644 doc/code/classes/Gitlab/GitLogger.html create mode 100644 doc/code/classes/Gitlab/GitStats.html create mode 100644 doc/code/classes/Gitlab/Gitolite.html create mode 100644 doc/code/classes/Gitlab/Gitolite/AccessDenied.html create mode 100644 doc/code/classes/Gitlab/GitoliteConfig.html create mode 100644 doc/code/classes/Gitlab/GitoliteConfig/PullError.html create mode 100644 doc/code/classes/Gitlab/GitoliteConfig/PushError.html create mode 100644 doc/code/classes/Gitlab/Graph.html create mode 100644 doc/code/classes/Gitlab/Graph/Commit.html create mode 100644 doc/code/classes/Gitlab/Graph/JsonBuilder.html create mode 100644 doc/code/classes/Gitlab/InlineDiff.html create mode 100644 doc/code/classes/Gitlab/Issues.html create mode 100644 doc/code/classes/Gitlab/Logger.html create mode 100644 doc/code/classes/Gitlab/Markdown.html create mode 100644 doc/code/classes/Gitlab/MergeRequests.html create mode 100644 doc/code/classes/Gitlab/Milestones.html create mode 100644 doc/code/classes/Gitlab/Notes.html create mode 100644 doc/code/classes/Gitlab/ProjectMover.html create mode 100644 doc/code/classes/Gitlab/ProjectMover/ProjectMoveError.html create mode 100644 doc/code/classes/Gitlab/Projects.html create mode 100644 doc/code/classes/Gitlab/Regex.html create mode 100644 doc/code/classes/Gitlab/Satellite.html create mode 100644 doc/code/classes/Gitlab/Satellite/Action.html create mode 100644 doc/code/classes/Gitlab/Satellite/EditFileAction.html create mode 100644 doc/code/classes/Gitlab/Satellite/MergeAction.html create mode 100644 doc/code/classes/Gitlab/Satellite/Satellite.html create mode 100644 doc/code/classes/Gitlab/Seeder.html create mode 100644 doc/code/classes/Gitlab/Session.html create mode 100644 doc/code/classes/Gitlab/Theme.html create mode 100644 doc/code/classes/Gitlab/Users.html (limited to 'doc/code/classes/Gitlab') diff --git a/doc/code/classes/Gitlab/API.html b/doc/code/classes/Gitlab/API.html new file mode 100644 index 00000000000..fe2ccc76ebe --- /dev/null +++ b/doc/code/classes/Gitlab/API.html @@ -0,0 +1,76 @@ + + + + + Gitlab::API + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/APIHelpers.html b/doc/code/classes/Gitlab/APIHelpers.html new file mode 100644 index 00000000000..603443dda2b --- /dev/null +++ b/doc/code/classes/Gitlab/APIHelpers.html @@ -0,0 +1,703 @@ + + + + + Gitlab::APIHelpers + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
A
+
+ +
+ +
C
+
+ +
+ +
F
+
+ +
+ +
N
+
+ +
+ +
P
+
+ +
+ +
R
+
+ +
+ +
U
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
Instance Public methods
+ +
+
+ + attributes_for_keys(keys) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 44
+def attributes_for_keys(keys)
+  attrs = {}
+  keys.each do |key|
+    attrs[key] = params[key] if params[key].present?
+  end
+  attrs
+end
+
+
+ +
+ +
+
+ + authenticate!() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 26
+def authenticate!
+  unauthorized! unless current_user
+end
+
+
+ +
+ +
+
+ + authenticated_as_admin!() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 30
+def authenticated_as_admin!
+  forbidden! unless current_user.is_admin?
+end
+
+
+ +
+ +
+
+ + authorize!(action, subject) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 34
+def authorize! action, subject
+  unless abilities.allowed?(current_user, action, subject)
+    forbidden!
+  end
+end
+
+
+ +
+ +
+
+ + can?(object, action, subject) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 40
+def can?(object, action, subject)
+  abilities.allowed?(object, action, subject)
+end
+
+
+ +
+ +
+
+ + current_user() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 3
+def current_user
+  @current_user ||= User.find_by_authentication_token(params[:private_token] || env["HTTP_PRIVATE_TOKEN"])
+end
+
+
+ +
+ +
+
+ + find_project() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 12
+def find_project
+  project = Project.find_by_id(params[:id]) || Project.find_with_namespace(params[:id])
+
+  if project && can?(current_user, :read_project, project)
+    project
+  else
+    nil
+  end
+end
+
+
+ +
+ +
+
+ + forbidden!() + + +
+ + +
+

error helpers

+
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 54
+def forbidden!
+  render_api_error!('403 Forbidden', 403)
+end
+
+
+ +
+ +
+
+ + not_allowed!() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 69
+def not_allowed!
+  render_api_error!('Method Not Allowed', 405)
+end
+
+
+ +
+ +
+
+ + not_found!(resource = nil) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 58
+def not_found!(resource = nil)
+  message = ["404"]
+  message << resource if resource
+  message << "Not Found"
+  render_api_error!(message.join(' '), 404)
+end
+
+
+ +
+ +
+
+ + paginate(object) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 22
+def paginate(object)
+  object.page(params[:page]).per(params[:per_page].to_i)
+end
+
+
+ +
+ +
+
+ + render_api_error!(message, status) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 73
+def render_api_error!(message, status)
+  error!({'message' => message}, status)
+end
+
+
+ +
+ +
+
+ + unauthorized!() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 65
+def unauthorized!
+  render_api_error!('401 Unauthorized', 401)
+end
+
+
+ +
+ +
+
+ + user_project() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/api/helpers.rb, line 7
+def user_project
+  @project ||= find_project
+  @project || not_found!
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/AppLogger.html b/doc/code/classes/Gitlab/AppLogger.html new file mode 100644 index 00000000000..2f4dc5349e3 --- /dev/null +++ b/doc/code/classes/Gitlab/AppLogger.html @@ -0,0 +1,173 @@ + + + + + Gitlab::AppLogger + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
F
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
Class Public methods
+ +
+
+ + file_name() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/app_logger.rb, line 3
+def self.file_name
+  'application.log'
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + format_message(severity, timestamp, progname, msg) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/app_logger.rb, line 7
+def format_message(severity, timestamp, progname, msg)
+  "#{timestamp.to_s(:long)}: #{msg}\n"
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Application.html b/doc/code/classes/Gitlab/Application.html new file mode 100644 index 00000000000..c8a1e3c2698 --- /dev/null +++ b/doc/code/classes/Gitlab/Application.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Application + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Auth.html b/doc/code/classes/Gitlab/Auth.html new file mode 100644 index 00000000000..4eeb3fecbc5 --- /dev/null +++ b/doc/code/classes/Gitlab/Auth.html @@ -0,0 +1,315 @@ + + + + + Gitlab::Auth + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
C
+
+ +
+ +
F
+
+ +
+ +
L
+
+
    + + +
  • + log +
  • + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + +
Instance Public methods
+ +
+
+ + create_from_omniauth(auth, ldap = false) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/auth.rb, line 20
+def create_from_omniauth(auth, ldap = false)
+  provider = auth.provider
+  uid = auth.info.uid || auth.uid
+  name = auth.info.name.force_encoding("utf-8")
+  email = auth.info.email.downcase unless auth.info.email.nil?
+
+  ldap_prefix = ldap ? '(LDAP) ' : ''
+  raise OmniAuth::Error, "#{ldap_prefix}#{provider} does not provide an email"         " address" if auth.info.email.blank?
+
+  log.info "#{ldap_prefix}Creating user from #{provider} login"         " {uid => #{uid}, name => #{name}, email => #{email}}"
+  password = Devise.friendly_token[0, 8].downcase
+  @user = User.new({
+    extern_uid: uid,
+    provider: provider,
+    name: name,
+    username: email.match(%r^[^@]*/)[0],
+    email: email,
+    password: password,
+    password_confirmation: password,
+    projects_limit: Gitlab.config.gitlab.default_projects_limit,
+  }, as: :admin)
+  if Gitlab.config.omniauth['block_auto_created_users'] && !ldap
+    @user.blocked = true
+  end
+  @user.save!
+  @user
+end
+
+
+ +
+ +
+
+ + find_for_ldap_auth(auth, signed_in_resource = nil) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/auth.rb, line 3
+def find_for_ldap_auth(auth, signed_in_resource = nil)
+  uid = auth.info.uid
+  provider = auth.provider
+  email = auth.info.email.downcase unless auth.info.email.nil?
+  raise OmniAuth::Error, "LDAP accounts must provide an uid and email address" if uid.nil? or email.nil?
+
+  if @user = User.find_by_extern_uid_and_provider(uid, provider)
+    @user
+  elsif @user = User.find_by_email(email)
+    log.info "Updating legacy LDAP user #{email} with extern_uid => #{uid}"
+    @user.update_attributes(:extern_uid => uid, :provider => provider)
+    @user
+  else
+    create_from_omniauth(auth, true)
+  end
+end
+
+
+ +
+ +
+
+ + find_or_new_for_omniauth(auth) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/auth.rb, line 50
+def find_or_new_for_omniauth(auth)
+  provider, uid = auth.provider, auth.uid
+  email = auth.info.email.downcase unless auth.info.email.nil?
+
+  if @user = User.find_by_provider_and_extern_uid(provider, uid)
+    @user
+  elsif @user = User.find_by_email(email)
+    @user.update_attributes(:extern_uid => uid, :provider => provider)
+    @user
+  else
+    if Gitlab.config.omniauth['allow_single_sign_on']
+      @user = create_from_omniauth(auth)
+      @user
+    end
+  end
+end
+
+
+ +
+ +
+
+ + log() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/auth.rb, line 67
+def log
+  Gitlab::AppLogger
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities.html b/doc/code/classes/Gitlab/Entities.html new file mode 100644 index 00000000000..8cb9ed35679 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities.html @@ -0,0 +1,151 @@ + + + + + Gitlab::Entities + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
Namespace
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/Hook.html b/doc/code/classes/Gitlab/Entities/Hook.html new file mode 100644 index 00000000000..a42cc91d4a3 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/Hook.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::Hook + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/Issue.html b/doc/code/classes/Gitlab/Entities/Issue.html new file mode 100644 index 00000000000..432c6f4bc14 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/Issue.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::Issue + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/MRNote.html b/doc/code/classes/Gitlab/Entities/MRNote.html new file mode 100644 index 00000000000..e05a43b8e54 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/MRNote.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::MRNote + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/MergeRequest.html b/doc/code/classes/Gitlab/Entities/MergeRequest.html new file mode 100644 index 00000000000..e68077163e7 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/MergeRequest.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::MergeRequest + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/Milestone.html b/doc/code/classes/Gitlab/Entities/Milestone.html new file mode 100644 index 00000000000..3c375faa8fb --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/Milestone.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::Milestone + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/Note.html b/doc/code/classes/Gitlab/Entities/Note.html new file mode 100644 index 00000000000..f0ba6567df5 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/Note.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::Note + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/Project.html b/doc/code/classes/Gitlab/Entities/Project.html new file mode 100644 index 00000000000..a111b19ffd2 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/Project.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::Project + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/ProjectMember.html b/doc/code/classes/Gitlab/Entities/ProjectMember.html new file mode 100644 index 00000000000..151abf270d2 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/ProjectMember.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::ProjectMember + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/ProjectSnippet.html b/doc/code/classes/Gitlab/Entities/ProjectSnippet.html new file mode 100644 index 00000000000..61259d0c0d1 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/ProjectSnippet.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::ProjectSnippet + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/RepoCommit.html b/doc/code/classes/Gitlab/Entities/RepoCommit.html new file mode 100644 index 00000000000..3d181a6f268 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/RepoCommit.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::RepoCommit + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/RepoObject.html b/doc/code/classes/Gitlab/Entities/RepoObject.html new file mode 100644 index 00000000000..ee6a10e7a6a --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/RepoObject.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::RepoObject + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/SSHKey.html b/doc/code/classes/Gitlab/Entities/SSHKey.html new file mode 100644 index 00000000000..cbc4d1a3a6b --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/SSHKey.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::SSHKey + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/User.html b/doc/code/classes/Gitlab/Entities/User.html new file mode 100644 index 00000000000..5c29667639e --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/User.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::User + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/UserBasic.html b/doc/code/classes/Gitlab/Entities/UserBasic.html new file mode 100644 index 00000000000..a17b808def4 --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/UserBasic.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::UserBasic + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Entities/UserLogin.html b/doc/code/classes/Gitlab/Entities/UserLogin.html new file mode 100644 index 00000000000..d73be2ca6ca --- /dev/null +++ b/doc/code/classes/Gitlab/Entities/UserLogin.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Entities::UserLogin + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/GitLogger.html b/doc/code/classes/Gitlab/GitLogger.html new file mode 100644 index 00000000000..19018c0fc7c --- /dev/null +++ b/doc/code/classes/Gitlab/GitLogger.html @@ -0,0 +1,173 @@ + + + + + Gitlab::GitLogger + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
F
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
Class Public methods
+ +
+
+ + file_name() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_logger.rb, line 3
+def self.file_name
+  'githost.log'
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + format_message(severity, timestamp, progname, msg) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_logger.rb, line 7
+def format_message(severity, timestamp, progname, msg)
+  "#{timestamp.to_s(:long)} -> #{severity} -> #{msg}\n"
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/GitStats.html b/doc/code/classes/Gitlab/GitStats.html new file mode 100644 index 00000000000..fabe18bb4d7 --- /dev/null +++ b/doc/code/classes/Gitlab/GitStats.html @@ -0,0 +1,506 @@ + + + + + Gitlab::GitStats + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
A
+
+ +
+ +
B
+
+ +
+ +
C
+
+ +
+ +
F
+
+ +
+ +
G
+
+ +
+ +
N
+
+
    + + +
  • + new +
  • + +
+
+ +
+ + + + + + + + + + + + + + + + + +
Attributes
+ + + + + + + + + + + + + + +
+ [RW] + ref
+ [RW] + repo
+ + + + + +
Class Public methods
+ +
+
+ + new(repo, ref) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_stats.rb, line 5
+def initialize repo, ref
+  @repo, @ref = repo, ref
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + authors() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_stats.rb, line 9
+def authors
+  @authors ||= collect_authors
+end
+
+
+ +
+ +
+
+ + authors_count() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_stats.rb, line 22
+def authors_count
+  authors.size
+end
+
+
+ +
+ +
+
+ + commits_count() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_stats.rb, line 13
+def commits_count
+  @commits_count ||= repo.commit_count(ref)
+end
+
+
+ +
+ +
+
+ + files_count() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_stats.rb, line 17
+def files_count
+  args = [ref, '-r', '--name-only' ]
+  repo.git.run(nil, 'ls-tree', nil, {}, args).split("\n").count
+end
+
+
+ +
+ +
+
+ + graph() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_stats.rb, line 26
+def graph
+  @graph ||= build_graph
+end
+
+
+ +
+ +
Instance Protected methods
+ +
+
+ + build_graph(n = 4) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_stats.rb, line 54
+def build_graph n = 4
+  from, to = (Date.today - n.weeks), Date.today
+  args = ['--all', "--since=#{from.to_s(:date)}", '--format=%ad' ]
+  rev_list = repo.git.run(nil, 'rev-list', nil, {}, args).split("\n")
+
+  commits_dates = rev_list.values_at(* rev_list.each_index.select {|i| i.odd?})
+  commits_dates = commits_dates.map { |date_str| Time.parse(date_str).to_date.to_s(:date) }
+
+  commits_per_day = from.upto(to).map do |day|
+    commits_dates.count(day.to_date.to_s(:date))
+  end
+
+  OpenStruct.new(
+    labels: from.upto(to).map { |day| day.stamp('Aug 23') },
+    commits: commits_per_day,
+    weeks: n
+  )
+end
+
+
+ +
+ +
+
+ + collect_authors() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/git_stats.rb, line 32
+def collect_authors
+  shortlog = repo.git.shortlog({e: true, s: true }, ref)
+
+  authors = []
+
+  lines = shortlog.split("\n")
+
+  lines.each do |line|
+    data = line.split("\t")
+    commits = data.first
+    author = Grit::Actor.from_string(data.last)
+
+    authors << OpenStruct.new(
+      name: author.name,
+      email: author.email,
+      commits: commits.to_i
+    )
+  end
+
+  authors.sort_by(&:commits).reverse
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Gitolite.html b/doc/code/classes/Gitlab/Gitolite.html new file mode 100644 index 00000000000..8cf9c58c375 --- /dev/null +++ b/doc/code/classes/Gitlab/Gitolite.html @@ -0,0 +1,536 @@ + + + + + Gitlab::Gitolite + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
Namespace
+ + + + + + +
Methods
+
+ +
C
+
+ +
+ +
E
+
+ +
+ +
M
+
+ +
+ +
R
+
+ +
+ +
S
+
+ +
+ +
U
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
Instance Public methods
+ +
+
+ + config() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite.rb, line 7
+def config
+  Gitlab::GitoliteConfig.new
+end
+
+
+ +
+ +
+
+ + create_repository(project) + + +
+ + +
+ +
+ + + + + +
+ +
+
+ + enable_automerge() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite.rb, line 44
+def enable_automerge
+  config.admin_all_repo!
+end
+
+
+ +
+ +
+
+ + move_repository(old_repo, project) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite.rb, line 29
+def move_repository(old_repo, project)
+  config.apply do |config|
+    config.clean_repo(old_repo)
+    config.update_project(project)
+  end
+end
+
+
+ +
+ +
+
+ + remove_key(key_id, projects) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite.rb, line 18
+def remove_key key_id, projects
+  config.apply do |config|
+    config.rm_key(key_id)
+    config.update_projects(projects)
+  end
+end
+
+
+ +
+ +
+
+ + remove_repository(project) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite.rb, line 36
+def remove_repository project
+  config.destroy_project!(project)
+end
+
+
+ +
+ +
+
+ + set_key(key_id, key_content, projects) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite.rb, line 11
+def set_key key_id, key_content, projects
+  config.apply do |config|
+    config.write_key(key_id, key_content)
+    config.update_projects(projects)
+  end
+end
+
+
+ +
+ +
+
+ + update_repositories(projects) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite.rb, line 48
+def update_repositories projects
+  config.apply do |config|
+    config.update_projects(projects)
+  end
+end
+
+
+ +
+ +
+
+ + update_repository(project) + + +
+ + +
+ +
+ + + +
+ Also aliased as: create_repository +
+ + + + +
+ + +
+
# File lib/gitlab/backend/gitolite.rb, line 25
+def update_repository project
+  config.update_project!(project)
+end
+
+
+ +
+ +
+
+ + url_to_repo(path) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite.rb, line 40
+def url_to_repo path
+  Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git"
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Gitolite/AccessDenied.html b/doc/code/classes/Gitlab/Gitolite/AccessDenied.html new file mode 100644 index 00000000000..8a45dae1ba2 --- /dev/null +++ b/doc/code/classes/Gitlab/Gitolite/AccessDenied.html @@ -0,0 +1,76 @@ + + + + + Gitlab::Gitolite::AccessDenied + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/GitoliteConfig.html b/doc/code/classes/Gitlab/GitoliteConfig.html new file mode 100644 index 00000000000..11026f5ca44 --- /dev/null +++ b/doc/code/classes/Gitlab/GitoliteConfig.html @@ -0,0 +1,810 @@ + + + + + Gitlab::GitoliteConfig + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
Namespace
+ + + + + + +
Methods
+
+ +
A
+
+ +
+ +
C
+
+ +
+ +
D
+
+ +
+ +
L
+
+
    + + +
  • + log +
  • + +
+
+ +
R
+
+ +
+ +
U
+
+ +
+ +
W
+
+ +
+ +
+ + + + + + + + + + + + + + + + + +
Attributes
+ + + + + + + + + + + + + + + + + + + + +
+ [R] + conf
+ [R] + config_tmp_dir
+ [R] + ga_repo
+ + + + + +
Instance Public methods
+ +
+
+ + admin_all_repo() + + +
+ + +
+

Enable access to all repos for gitolite admin. We use it for accept merge +request feature

+
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 169
+def admin_all_repo
+  owner_name = Gitlab.config.gitolite.admin_key
+
+  # @ALL repos premission for gitolite owner
+  repo_name = "@all"
+  repo = if conf.has_repo?(repo_name)
+           conf.get_repo(repo_name)
+         else
+           ::Gitolite::Config::Repo.new(repo_name)
+         end
+
+  repo.add_permission("RW+", "", owner_name)
+  conf.add_repo(repo, true)
+end
+
+
+ +
+ +
+
+ + admin_all_repo!() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 184
+def admin_all_repo!
+  apply { |config| config.admin_all_repo }
+end
+
+
+ +
+ +
+
+ + apply() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 23
+def apply
+  Timeout::timeout(30) do
+    File.open(Rails.root.join('tmp', "gitlabhq-gitolite.lock"), "w+") do |f|
+      begin
+        # Set exclusive lock
+        # to prevent race condition
+        f.flock(File::LOCK_EX)
+
+        # Pull gitolite-admin repo
+        # in tmp dir before do any changes
+        pull(config_tmp_dir)
+
+        # Build ga_repo object and @conf
+        # to access gitolite-admin configuration
+        @conf = ga_repo.config
+
+        # Do any changes
+        # in gitolite-admin
+        # config here
+        yield(self)
+
+        # Save changes in
+        # gitolite-admin repo
+        # before push it
+        ga_repo.save
+
+        # Push gitolite-admin repo
+        # to apply all changes
+        push(config_tmp_dir)
+      ensure
+        # Remove tmp dir
+        # removing the gitolite folder first is important to avoid
+        # NFS issues.
+        FileUtils.rm_rf(File.join(config_tmp_dir, 'gitolite'))
+
+        # Remove parent tmp dir
+        FileUtils.rm_rf(config_tmp_dir)
+
+        # Unlock so other task can access
+        # gitolite configuration
+        f.flock(File::LOCK_UN)
+      end
+    end
+  end
+rescue PullError => ex
+  log("Pull error ->  " + ex.message)
+  raise Gitolite::AccessDenied, ex.message
+
+rescue PushError => ex
+  log("Push error ->  " + " " + ex.message)
+  raise Gitolite::AccessDenied, ex.message
+
+rescue Exception => ex
+  log(ex.class.name + " " + ex.message)
+  raise Gitolite::AccessDenied.new("gitolite timeout")
+end
+
+
+ +
+ +
+
+ + clean_repo(repo_name) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 89
+def clean_repo repo_name
+  conf.rm_repo(repo_name)
+end
+
+
+ +
+ +
+
+ + destroy_project(project) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 84
+def destroy_project(project)
+  FileUtils.rm_rf(project.path_to_repo)
+  conf.rm_repo(project.path_with_namespace)
+end
+
+
+ +
+ +
+
+ + destroy_project!(project) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 93
+def destroy_project!(project)
+  apply do |config|
+    config.destroy_project(project)
+  end
+end
+
+
+ +
+ +
+
+ + log(message) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 80
+def log message
+  Gitlab::GitLogger.error(message)
+end
+
+
+ +
+ +
+
+ + rm_key(user) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 105
+def rm_key(user)
+  key_path = File.join(config_tmp_dir, 'gitolite/keydir', "#{user}.pub")
+  ga_key = ::Gitolite::SSHKey.from_file(key_path)
+  ga_repo.rm_key(ga_key)
+end
+
+
+ +
+ +
+
+ + update_project(project) + + +
+ + +
+

update or create

+
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 112
+def update_project(project)
+  repo = update_project_config(project, conf)
+  conf.add_repo(repo, true)
+end
+
+
+ +
+ +
+
+ + update_project!( project) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 117
+def update_project!( project)
+  apply do |config|
+    config.update_project(project)
+  end
+end
+
+
+ +
+ +
+
+ + update_project_config(project, conf) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 132
+def update_project_config(project, conf)
+  repo_name = project.path_with_namespace
+
+  repo = if conf.has_repo?(repo_name)
+           conf.get_repo(repo_name)
+         else
+           ::Gitolite::Config::Repo.new(repo_name)
+         end
+
+  name_readers = project.repository_readers
+  name_writers = project.repository_writers
+  name_masters = project.repository_masters
+
+  pr_br = project.protected_branches.map(&:name).join("$ ")
+
+  repo.clean_permissions
+
+  # Deny access to protected branches for writers
+  unless name_writers.blank? || pr_br.blank?
+    repo.add_permission("-", pr_br.strip + "$ ", name_writers)
+  end
+
+  # Add read permissions
+  repo.add_permission("R", "", name_readers) unless name_readers.blank?
+
+  # Add write permissions
+  repo.add_permission("RW+", "", name_writers) unless name_writers.blank?
+  repo.add_permission("RW+", "", name_masters) unless name_masters.blank?
+
+  # Add sharedRepository config
+  repo.set_git_config("core.sharedRepository", "0660")
+
+  repo
+end
+
+
+ +
+ +
+
+ + update_projects(projects) + + +
+ + +
+

Updates many projects and uses project.path_with_namespace as the repo path +An order of magnitude faster than #update_project

+
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 125
+def update_projects(projects)
+  projects.each do |project|
+    repo = update_project_config(project, conf)
+    conf.add_repo(repo, true)
+  end
+end
+
+
+ +
+ +
+
+ + write_key(id, key) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 99
+def write_key(id, key)
+  File.open(File.join(config_tmp_dir, 'gitolite/keydir',"#{id}.pub"), 'w') do |f|
+    f.write(key.gsub(%r\n/,''))
+  end
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/GitoliteConfig/PullError.html b/doc/code/classes/Gitlab/GitoliteConfig/PullError.html new file mode 100644 index 00000000000..35c46f38642 --- /dev/null +++ b/doc/code/classes/Gitlab/GitoliteConfig/PullError.html @@ -0,0 +1,76 @@ + + + + + Gitlab::GitoliteConfig::PullError + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/GitoliteConfig/PushError.html b/doc/code/classes/Gitlab/GitoliteConfig/PushError.html new file mode 100644 index 00000000000..53efe1e8a7d --- /dev/null +++ b/doc/code/classes/Gitlab/GitoliteConfig/PushError.html @@ -0,0 +1,76 @@ + + + + + Gitlab::GitoliteConfig::PushError + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Graph.html b/doc/code/classes/Gitlab/Graph.html new file mode 100644 index 00000000000..e0827c84594 --- /dev/null +++ b/doc/code/classes/Gitlab/Graph.html @@ -0,0 +1,88 @@ + + + + + Gitlab::Graph + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
Namespace
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Graph/Commit.html b/doc/code/classes/Gitlab/Graph/Commit.html new file mode 100644 index 00000000000..0198b3f0e3c --- /dev/null +++ b/doc/code/classes/Gitlab/Graph/Commit.html @@ -0,0 +1,337 @@ + + + + + Gitlab::Graph::Commit + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
A
+
+ +
+ +
M
+
+ +
+ +
N
+
+
    + + +
  • + new +
  • + +
+
+ +
T
+
+ +
+ +
+ + + + +
Included Modules
+
    + +
  • + + ActionView::Helpers::TagHelper + +
  • + +
+ + + + + + + + + + + + + + + +
Attributes
+ + + + + + + + + + + + + + + + + + + + +
+ [RW] + refs
+ [RW] + space
+ [RW] + time
+ + + + + +
Class Public methods
+ +
+
+ + new(commit) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/commit.rb, line 10
+def initialize(commit)
+  @_commit = commit
+  @time = -1
+  @space = 0
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + add_refs(ref_cache, repo) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/commit.rb, line 36
+def add_refs(ref_cache, repo)
+  if ref_cache.empty?
+    repo.refs.each do |ref|
+      ref_cache[ref.commit.id] ||= []
+      ref_cache[ref.commit.id] << ref
+    end
+  end
+  @refs = ref_cache[@_commit.id] if ref_cache.include?(@_commit.id)
+  @refs ||= []
+end
+
+
+ +
+ +
+
+ + method_missing(m, *args, &block) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/commit.rb, line 16
+def method_missing(m, *args, &block)
+  @_commit.send(m, *args, &block)
+end
+
+
+ +
+ +
+
+ + to_graph_hash() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/commit.rb, line 20
+def to_graph_hash
+  h = {}
+  h[:parents] = self.parents.collect do |p|
+    [p.id,0,0]
+  end
+  h[:author]  = author.name
+  h[:time]    = time
+  h[:space]   = space
+  h[:refs]    = refs.collect{|r|r.name}.join(" ") unless refs.nil?
+  h[:id]      = sha
+  h[:date]    = date
+  h[:message] = message
+  h[:login]   = author.email
+  h
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Graph/JsonBuilder.html b/doc/code/classes/Gitlab/Graph/JsonBuilder.html new file mode 100644 index 00000000000..b410947bb85 --- /dev/null +++ b/doc/code/classes/Gitlab/Graph/JsonBuilder.html @@ -0,0 +1,707 @@ + + + + + Gitlab::Graph::JsonBuilder + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
B
+
+ +
+ +
C
+
+ +
+ +
F
+
+ +
+ +
I
+
+ +
+ +
M
+
+ +
+ +
N
+
+
    + + +
  • + new +
  • + +
+
+ +
P
+
+ +
+ +
T
+
+ +
+ +
+ + + + + + + + + + + + + + + + + +
Attributes
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ [RW] + commits
+ [RW] + days
+ [RW] + ref_cache
+ [RW] + repo
+ + + + + +
Class Public methods
+ +
+
+ + max_count() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 8
+def self.max_count
+  @max_count ||= 650
+end
+
+
+ +
+ +
+
+ + new(project) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 12
+def initialize project
+  @project = project
+  @repo = project.repo
+  @ref_cache = {}
+
+  @commits = collect_commits
+  @days = index_commits
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + to_json(*args) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 21
+def to_json(*args)
+  {
+    days: @days.compact.map { |d| [d.day, d.strftime("%b")] },
+    commits: @commits.map(&:to_graph_hash)
+  }.to_json(*args)
+end
+
+
+ +
+ +
Instance Protected methods
+ +
+
+ + base_space(leaves, map) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 148
+def base_space(leaves, map)
+  parents = []
+  leaves.each do |l|
+    parents.concat l.parents.collect.select{|p| map.include? p.id and map[p.id].space.nonzero?}
+  end
+
+  space = parents.map{|p| map[p.id].space}.max || 0
+  space += 1
+end
+
+
+ +
+ +
+
+ + collect_commits() + + +
+ + +
+

Get commits from repository

+
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 32
+def collect_commits
+  @commits = Grit::Commit.find_all(repo, nil, {max_count: self.class.max_count}).dup
+
+  # Decorate with app/models/commit.rb
+  @commits.map! { |commit| ::Commit.new(commit) }
+
+  # Decorate with lib/gitlab/graph/commit.rb
+  @commits.map! { |commit| Gitlab::Graph::Commit.new(commit) }
+
+  # add refs to each commit
+  @commits.each { |commit| commit.add_refs(ref_cache, repo) }
+
+  @commits
+end
+
+
+ +
+ +
+
+ + find_free_space(leaves, map) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 135
+def find_free_space(leaves, map)
+  time_range = leaves.last.time..leaves.first.time
+  reserved = []
+  for day in time_range
+    reserved += @_reserved[day]
+  end
+  space = base_space(leaves, map)
+  while reserved.include? space do
+    space += 1
+  end
+  space
+end
+
+
+ +
+ +
+
+ + index_commits() + + +
+ + +
+

Method is adding time and space on the list of commits. As well as returns +date list corelated with time set on commits.

+ +

@param [Array<Graph::Commit>] comits to index

+ +

@return [Array<TimeDate>] list of commit dates corelated with time on +commits

+
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 54
+def index_commits
+  days, heads = [], []
+  map = {}
+
+  commits.reverse.each_with_index do |c,i|
+    c.time = i
+    days[i] = c.committed_date
+    map[c.id] = c
+    heads += c.refs unless c.refs.nil?
+  end
+
+  heads.select!{|h| h.is_a? Grit::Head or h.is_a? Grit::Remote}
+  # sort heads so the master is top and current branches are closer
+  heads.sort! do |a,b|
+    if a.name == "master"
+      -1
+    elsif b.name == "master"
+      1
+    else
+      b.commit.committed_date <=> a.commit.committed_date
+    end
+  end
+
+  @_reserved = {}
+  days.each_index do |i|
+    @_reserved[i] = []
+  end
+
+  heads.each do |h|
+    if map.include? h.commit.id then
+      place_chain(map[h.commit.id], map)
+    end
+  end
+
+  days
+end
+
+
+ +
+ +
+
+ + mark_reserved(time_range, space) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 129
+def mark_reserved(time_range, space)
+  for day in time_range
+    @_reserved[day].push(space)
+  end
+end
+
+
+ +
+ +
+
+ + place_chain(commit, map, parent_time = nil) + + +
+ + +
+

Add space mark on commit and its parents

+ +

@param [Graph::Commit] the commit object. @param +[Hash<String,Graph::Commit>] map of commits

+
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 95
+def place_chain(commit, map, parent_time = nil)
+  leaves = take_left_leaves(commit, map)
+  if leaves.empty?
+    return
+  end
+  space = find_free_space(leaves, map)
+  leaves.each{|l| l.space = space}
+  # and mark it as reserved
+  min_time = leaves.last.time
+  parents = leaves.last.parents.collect
+  parents.each do |p|
+    if map.include? p.id
+      parent = map[p.id]
+      if parent.time < min_time
+        min_time = parent.time
+      end
+    end
+  end
+  if parent_time.nil?
+    max_time = leaves.first.time
+  else
+    max_time = parent_time - 1
+  end
+  mark_reserved(min_time..max_time, space)
+
+  # Visit branching chains
+  leaves.each do |l|
+    parents = l.parents.collect.select{|p| map.include? p.id and map[p.id].space.zero?}
+    for p in parents
+      place_chain(map[p.id], map, l.time)
+    end
+  end
+end
+
+
+ +
+ +
+
+ + take_left_leaves(commit, map) + + +
+ + +
+

Takes most left subtree branch of commits which don’t have space mark yet.

+ +

@param [Graph::Commit] the commit object. @param +[Hash<String,Graph::Commit>] map of commits

+ +

@return [Array<Graph::Commit>] list of branch commits

+
+ + + + + + +
+ + +
+
# File lib/gitlab/graph/json_builder.rb, line 165
+def take_left_leaves(commit, map)
+  leaves = []
+  leaves.push(commit) if commit.space.zero?
+
+  while true
+    return leaves if commit.parents.count.zero?
+    return leaves unless map.include? commit.parents.first.id
+
+    commit = map[commit.parents.first.id]
+
+    return leaves unless commit.space.zero?
+
+    leaves.push(commit)
+  end
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/InlineDiff.html b/doc/code/classes/Gitlab/InlineDiff.html new file mode 100644 index 00000000000..cd04b7d018d --- /dev/null +++ b/doc/code/classes/Gitlab/InlineDiff.html @@ -0,0 +1,299 @@ + + + + + Gitlab::InlineDiff + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
#
+
+ +
+ +
P
+
+ +
+ +
R
+
+ +
+ +
+ + + + + + + + + + + + + + +
Constants
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
START="#!idiff-start!#"
 
FINISH="#!idiff-finish!#"
 
+ + + + + + + + +
Class Public methods
+ +
+
+ + _indexes_of_changed_lines(diff_arr) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/inline_diff.rb, line 42
+def _indexes_of_changed_lines diff_arr
+  chain_of_first_symbols = ""
+  diff_arr.each_with_index do |line, i|
+    chain_of_first_symbols += line[0]
+  end
+  chain_of_first_symbols.gsub!(%r[^\-\+]/, "#")
+
+  offset = 0
+  indexes = []
+  while index = chain_of_first_symbols.index("#-+#", offset)
+    indexes << index
+    offset = index + 1
+  end
+  indexes
+end
+
+
+ +
+ +
+
+ + processing(diff_arr) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/inline_diff.rb, line 8
+def processing diff_arr
+  indexes = _indexes_of_changed_lines diff_arr
+
+  indexes.each do |index|
+    first_line = diff_arr[index+1]
+    second_line = diff_arr[index+2]
+    max_length = [first_line.size, second_line.size].max
+
+    first_the_same_symbols = 0
+    (0..max_length + 1).each do |i|
+      first_the_same_symbols = i - 1
+      if first_line[i] != second_line[i] && i > 0
+        break
+      end
+    end
+    first_token = first_line[0..first_the_same_symbols][1..-1]
+    diff_arr[index+1].sub!(first_token, first_token + START)
+    diff_arr[index+2].sub!(first_token, first_token + START)
+    last_the_same_symbols = 0
+    (1..max_length + 1).each do |i|
+      last_the_same_symbols = -i
+      shortest_line = second_line.size > first_line.size ? first_line : second_line
+      if ( first_line[-i] != second_line[-i] ) || "#{first_token}#{START}".size == shortest_line[1..-i].size
+        break
+      end
+    end
+    last_the_same_symbols += 1
+    last_token = first_line[last_the_same_symbols..-1]
+    diff_arr[index+1].sub!(%r#{Regexp.escape(last_token)}$/, FINISH + last_token)
+    diff_arr[index+2].sub!(%r#{Regexp.escape(last_token)}$/, FINISH + last_token)
+  end
+  diff_arr
+end
+
+
+ +
+ +
+
+ + replace_markers(line) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/inline_diff.rb, line 58
+def replace_markers line
+  line.gsub!(START, "<span class='idiff'>")
+  line.gsub!(FINISH, "</span>")
+  line
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Issues.html b/doc/code/classes/Gitlab/Issues.html new file mode 100644 index 00000000000..91c6dead2a6 --- /dev/null +++ b/doc/code/classes/Gitlab/Issues.html @@ -0,0 +1,82 @@ + + + + + Gitlab::Issues + + + + + + + + + + + + + +
+
+ +
+ +

Issues API

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Logger.html b/doc/code/classes/Gitlab/Logger.html new file mode 100644 index 00000000000..2c523c19219 --- /dev/null +++ b/doc/code/classes/Gitlab/Logger.html @@ -0,0 +1,315 @@ + + + + + Gitlab::Logger + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
B
+
+ +
+ +
E
+
+ +
+ +
I
+
+
    + + +
  • + info +
  • + +
+
+ +
R
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
Class Public methods
+ +
+
+ + build() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/logger.rb, line 22
+def self.build
+  new(Rails.root.join("log", file_name))
+end
+
+
+ +
+ +
+
+ + error(message) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/logger.rb, line 3
+def self.error(message)
+  build.error(message)
+end
+
+
+ +
+ +
+
+ + info(message) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/logger.rb, line 7
+def self.info(message)
+  build.info(message)
+end
+
+
+ +
+ +
+
+ + read_latest() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/logger.rb, line 11
+def self.read_latest
+  path = Rails.root.join("log", file_name)
+  self.build unless File.exist?(path)
+  logs = %xtail -n 2000 #{path}`.split("\n")
+end
+
+
+ +
+ +
+
+ + read_latest_for(filename) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/logger.rb, line 17
+def self.read_latest_for filename
+  path = Rails.root.join("log", filename)
+  logs = %xtail -n 2000 #{path}`.split("\n")
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Markdown.html b/doc/code/classes/Gitlab/Markdown.html new file mode 100644 index 00000000000..45d853f3684 --- /dev/null +++ b/doc/code/classes/Gitlab/Markdown.html @@ -0,0 +1,258 @@ + + + + + Gitlab::Markdown + + + + + + + + + + + + + +
+
+ +
+ +

Custom parser for GitLab-flavored Markdown

+ +

It replaces references in the text with links to the appropriate items in +GitLab.

+ +

Supported reference formats are:

+ +
* @foo for team members
+* #123 for issues
+* !123 for merge requests
+* $123 for snippets
+* 123456 for commits
+ +

It also parses Emoji codes to insert images. See www.emoji-cheat-sheet.com/ for +a list of the supported icons.

+ +

Examples

+ +
>> gfm("Hey @david, can you fix this?")
+=> "Hey <a href="/gitlab/team_members/1">@david</a>, can you fix this?"
+
+>> gfm("Commit 35d5f7c closes #1234")
+=> "Commit <a href="/gitlab/commits/35d5f7c">35d5f7c</a> closes <a href="/gitlab/issues/1234">#1234</a>"
+
+>> gfm(":trollface:")
+=> "<img alt=\":trollface:\" class=\"emoji\" src=\"/images/trollface.png" title=\":trollface:\" />
+
+ +
+ + + + + + + + + + + + + + + +
Methods
+
+ +
G
+
+
    + + +
  • + gfm +
  • + +
+
+ +
+ + + + + + + + + + + + + + +
Constants
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
REFERENCE_PATTERN=%r{ +(?<prefix>\W)? # Prefix +( # Reference +@(?<user>[a-zA-Z][a-zA-Z0-9_\-\.]*) # User name +|\#(?<issue>\d+) # Issue ID +|!(?<merge_request>\d+) # MR ID +|\$(?<snippet>\d+) # Snippet ID +|(?<commit>[\h]{6,40}) # Commit ID +) +(?<suffix>\W)? # Suffix +}x.freeze
 
TYPES=[:user, :issue, :merge_request, :snippet, :commit].freeze
 
EMOJI_PATTERN=%r{(:(\S+):)}.freeze
 
+ + + + + +
Attributes
+ + + + + + + + +
+ [R] + html_options
+ + + + + +
Instance Public methods
+ +
+
+ + gfm(text, html_options = {}) + + +
+ + +
+

Public: Parse the provided text with GitLab-Flavored Markdown

+ +

text - the source text #html_options - extra +options for the reference links as given to link_to

+ +

Note: reference links will only be generated if @project is set

+
+ + + + + + +
+ + +
+
# File lib/gitlab/markdown.rb, line 52
+def gfm(text, html_options = {})
+  return text if text.nil?
+
+  # Duplicate the string so we don't alter the original, then call to_str
+  # to cast it back to a String instead of a SafeBuffer. This is required
+  # for gsub calls to work as we need them to.
+  text = text.dup.to_str
+
+  @html_options = html_options
+
+  # Extract pre blocks so they are not altered
+  # from http://github.github.com/github-flavored-markdown/
+  extractions = {}
+  text.gsub!(%r{<pre>.*?</pre>|<code>.*?</code>}) do |match|
+    md5 = Digest::MD5.hexdigest(match)
+    extractions[md5] = match
+    "{gfm-extraction-#{md5}}"
+  end
+
+  # TODO: add popups with additional information
+
+  text = parse(text)
+
+  # Insert pre block extractions
+  text.gsub!(%r\{gfm-extraction-(\h{32})\}/) do
+    extractions[$1]
+  end
+
+  sanitize text.html_safe, attributes: ActionView::Base.sanitized_allowed_attributes + %w(id class)
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/MergeRequests.html b/doc/code/classes/Gitlab/MergeRequests.html new file mode 100644 index 00000000000..556f2b01604 --- /dev/null +++ b/doc/code/classes/Gitlab/MergeRequests.html @@ -0,0 +1,82 @@ + + + + + Gitlab::MergeRequests + + + + + + + + + + + + + +
+
+ +
+ +

MergeRequest API

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Milestones.html b/doc/code/classes/Gitlab/Milestones.html new file mode 100644 index 00000000000..4226dab3d56 --- /dev/null +++ b/doc/code/classes/Gitlab/Milestones.html @@ -0,0 +1,82 @@ + + + + + Gitlab::Milestones + + + + + + + + + + + + + +
+
+ +
+ +

Milestones API

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Notes.html b/doc/code/classes/Gitlab/Notes.html new file mode 100644 index 00000000000..90d3e7af53a --- /dev/null +++ b/doc/code/classes/Gitlab/Notes.html @@ -0,0 +1,100 @@ + + + + + Gitlab::Notes + + + + + + + + + + + + + +
+
+ +
+ +

Notes API

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Constants
+ + + + + + + + + + + + + + +
NOTEABLE_TYPES=[Issue, Snippet]
 
+ + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/ProjectMover.html b/doc/code/classes/Gitlab/ProjectMover.html new file mode 100644 index 00000000000..d13cf13d375 --- /dev/null +++ b/doc/code/classes/Gitlab/ProjectMover.html @@ -0,0 +1,290 @@ + + + + + Gitlab::ProjectMover + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
Namespace
+ + + + + + +
Methods
+
+ +
E
+
+ +
+ +
L
+
+ +
+ +
N
+
+
    + + +
  • + new +
  • + +
+
+ +
+ + + + + + + + + + + + + + + + + +
Attributes
+ + + + + + + + + + + + + + + + + + + + +
+ [R] + new_dir
+ [R] + old_dir
+ [R] + project
+ + + + + +
Class Public methods
+ +
+
+ + new(project, old_dir, new_dir) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/project_mover.rb, line 10
+def initialize(project, old_dir, new_dir)
+  @project = project
+  @old_dir = old_dir
+  @new_dir = new_dir
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + execute() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/project_mover.rb, line 16
+def execute
+  # Create new dir if missing
+  new_dir_path = File.join(Gitlab.config.gitolite.repos_path, new_dir)
+  system("mkdir -m 770 #{new_dir_path}") unless File.exists?(new_dir_path)
+
+  old_path = File.join(Gitlab.config.gitolite.repos_path, old_dir, "#{project.path}.git")
+  new_path = File.join(new_dir_path, "#{project.path}.git")
+
+  if File.exists? new_path
+    raise ProjectMoveError.new("Destination #{new_path} already exists")
+  end
+
+  if system("mv #{old_path} #{new_path}")
+    log_info "Project #{project.name} was moved from #{old_path} to #{new_path}"
+    true
+  else
+    message = "Project #{project.name} cannot be moved from #{old_path} to #{new_path}"
+    log_info "Error! #{message}"
+    raise ProjectMoveError.new(message)
+  end
+end
+
+
+ +
+ +
Instance Protected methods
+ +
+
+ + log_info(message) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/project_mover.rb, line 40
+def log_info message
+  Gitlab::AppLogger.info message
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/ProjectMover/ProjectMoveError.html b/doc/code/classes/Gitlab/ProjectMover/ProjectMoveError.html new file mode 100644 index 00000000000..0071ba0c636 --- /dev/null +++ b/doc/code/classes/Gitlab/ProjectMover/ProjectMoveError.html @@ -0,0 +1,76 @@ + + + + + Gitlab::ProjectMover::ProjectMoveError + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Projects.html b/doc/code/classes/Gitlab/Projects.html new file mode 100644 index 00000000000..9005134ee6c --- /dev/null +++ b/doc/code/classes/Gitlab/Projects.html @@ -0,0 +1,82 @@ + + + + + Gitlab::Projects + + + + + + + + + + + + + +
+
+ +
+ +

Projects API

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Regex.html b/doc/code/classes/Gitlab/Regex.html new file mode 100644 index 00000000000..674df3227af --- /dev/null +++ b/doc/code/classes/Gitlab/Regex.html @@ -0,0 +1,261 @@ + + + + + Gitlab::Regex + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
D
+
+ +
+ +
P
+
+ +
+ +
U
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
Instance Public methods
+ +
+
+ + path_regex() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/regex.rb, line 13
+def path_regex
+  default_regex
+end
+
+
+ +
+ +
+
+ + project_name_regex() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/regex.rb, line 9
+def project_name_regex
+  %r\A[a-zA-Z][a-zA-Z0-9_\-\. ]*\z/
+end
+
+
+ +
+ +
+
+ + username_regex() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/regex.rb, line 5
+def username_regex
+  default_regex
+end
+
+
+ +
+ +
Instance Protected methods
+ +
+
+ + default_regex() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/regex.rb, line 19
+def default_regex
+  %r\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Satellite.html b/doc/code/classes/Gitlab/Satellite.html new file mode 100644 index 00000000000..943bbf8eeab --- /dev/null +++ b/doc/code/classes/Gitlab/Satellite.html @@ -0,0 +1,102 @@ + + + + + Gitlab::Satellite + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
Namespace
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Satellite/Action.html b/doc/code/classes/Gitlab/Satellite/Action.html new file mode 100644 index 00000000000..abe7411ef1f --- /dev/null +++ b/doc/code/classes/Gitlab/Satellite/Action.html @@ -0,0 +1,305 @@ + + + + + Gitlab::Satellite::Action + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
I
+
+ +
+ +
N
+
+
    + + +
  • + new +
  • + +
+
+ +
P
+
+ +
+ +
+ + + + + + + + + + + + + + +
Constants
+ + + + + + + + + + + + + + +
DEFAULT_OPTIONS={ git_timeout: 30.seconds }
 
+ + + + + +
Attributes
+ + + + + + + + + + + + + + + + + + + + +
+ [RW] + options
+ [RW] + project
+ [RW] + user
+ + + + + +
Class Public methods
+ +
+
+ + new(user, project, options = {}) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/action.rb, line 8
+def initialize(user, project, options = {})
+  @options = DEFAULT_OPTIONS.merge(options)
+  @project = project
+  @user = user
+end
+
+
+ +
+ +
Instance Protected methods
+ +
+
+ + in_locked_and_timed_satellite() + + +
+ + +
+
  • +

    Sets a 30s timeout for Git

    +
  • +

    Locks the satellite repo

    +
  • +

    Yields the prepared satellite repo

    +
+
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/action.rb, line 19
+def in_locked_and_timed_satellite
+  Grit::Git.with_timeout(options[:git_timeout]) do
+    project.satellite.lock do
+      return yield project.satellite.repo
+    end
+  end
+rescue Errno::ENOMEM => ex
+  Gitlab::GitLogger.error(ex.message)
+  return false
+rescue Grit::Git::GitTimeout => ex
+  Gitlab::GitLogger.error(ex.message)
+  return false
+end
+
+
+ +
+ +
+
+ + prepare_satellite!(repo) + + +
+ + +
+
  • +

    Clears the satellite

    +
  • +

    Updates the satellite from Gitolite

    +
  • +

    Sets up Git variables for the user

    +
+ +

Note: use this within in_locked_and_timed_satellite

+
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/action.rb, line 38
+def prepare_satellite!(repo)
+  project.satellite.clear_and_update!
+
+  repo.git.config({}, "user.name", user.name)
+  repo.git.config({}, "user.email", user.email)
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Satellite/EditFileAction.html b/doc/code/classes/Gitlab/Satellite/EditFileAction.html new file mode 100644 index 00000000000..3a35aa22632 --- /dev/null +++ b/doc/code/classes/Gitlab/Satellite/EditFileAction.html @@ -0,0 +1,284 @@ + + + + + Gitlab::Satellite::EditFileAction + + + + + + + + + + + + + +
+
+ +
+ +

GitLab server-side file update and commit

+ +
+ + + + + + + + + + + + + + + +
Methods
+
+ +
C
+
+ +
+ +
N
+
+
    + + +
  • + new +
  • + +
+
+ +
+ + + + + + + + + + + + + + + + + +
Attributes
+ + + + + + + + + + + + + + +
+ [RW] + file_path
+ [RW] + ref
+ + + + + +
Class Public methods
+ +
+
+ + new(user, project, ref, file_path) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/edit_file_action.rb, line 7
+def initialize(user, project, ref, file_path)
+  super user, project, git_timeout: 10.seconds
+  @file_path = file_path
+  @ref = ref
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + commit!(content, commit_message, last_commit) + + +
+ + +
+

Updates the files content and creates a new commit for it

+ +

Returns false if the ref has been updated while editing the file Returns +false if commiting the change fails Returns false if pushing from the +satellite to Gitolite failed or was rejected +Returns true otherwise

+
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/edit_file_action.rb, line 19
+def commit!(content, commit_message, last_commit)
+  return false unless can_edit?(last_commit)
+
+  in_locked_and_timed_satellite do |repo|
+    prepare_satellite!(repo)
+
+    # create target branch in satellite at the corresponding commit from Gitolite
+    repo.git.checkout({raise: true, timeout: true, b: true}, ref, "origin/#{ref}")
+
+    # update the file in the satellite's working dir
+    file_path_in_satellite = File.join(repo.working_dir, file_path)
+    File.open(file_path_in_satellite, 'w') { |f| f.write(content) }
+
+    # commit the changes
+    # will raise CommandFailed when commit fails
+    repo.git.commit(raise: true, timeout: true, a: true, m: commit_message)
+
+
+    # push commit back to Gitolite
+    # will raise CommandFailed when push fails
+    repo.git.push({raise: true, timeout: true}, :origin, ref)
+
+    # everything worked
+    true
+  end
+rescue Grit::Git::CommandFailed => ex
+  Gitlab::GitLogger.error(ex.message)
+  false
+end
+
+
+ +
+ +
Instance Protected methods
+ +
+
+ + can_edit?(last_commit) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/edit_file_action.rb, line 51
+def can_edit?(last_commit)
+  current_last_commit = @project.last_commit_for(ref, file_path).sha
+  last_commit == current_last_commit
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Satellite/MergeAction.html b/doc/code/classes/Gitlab/Satellite/MergeAction.html new file mode 100644 index 00000000000..064c4f06e60 --- /dev/null +++ b/doc/code/classes/Gitlab/Satellite/MergeAction.html @@ -0,0 +1,274 @@ + + + + + Gitlab::Satellite::MergeAction + + + + + + + + + + + + + +
+
+ +
+ +

GitLab server-side merge

+ +
+ + + + + + + + + + + + + + + +
Methods
+
+ +
C
+
+ +
+ +
M
+
+ +
+ +
N
+
+
    + + +
  • + new +
  • + +
+
+ +
+ + + + + + + + + + + + + + + + + +
Attributes
+ + + + + + + + +
+ [RW] + merge_request
+ + + + + +
Class Public methods
+ +
+
+ + new(user, merge_request) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/merge_action.rb, line 7
+def initialize(user, merge_request)
+  super user, merge_request.project
+  @merge_request = merge_request
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + can_be_merged?() + + +
+ + +
+

Checks if a merge request can be executed without user interaction

+
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/merge_action.rb, line 13
+def can_be_merged?
+  in_locked_and_timed_satellite do |merge_repo|
+    merge_in_satellite!(merge_repo)
+  end
+end
+
+
+ +
+ +
+
+ + merge!() + + +
+ + +
+

Merges the source branch into the target branch in the satellite and pushes +it back to Gitolite. It also removes the +source branch if requested in the merge request.

+ +

Returns false if the merge produced conflicts Returns false if pushing from +the satellite to Gitolite failed or was +rejected Returns true otherwise

+
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/merge_action.rb, line 26
+def merge!
+  in_locked_and_timed_satellite do |merge_repo|
+    if merge_in_satellite!(merge_repo)
+      # push merge back to Gitolite
+      # will raise CommandFailed when push fails
+      merge_repo.git.push({raise: true, timeout: true}, :origin, merge_request.target_branch)
+
+      # remove source branch
+      if merge_request.should_remove_source_branch && !project.root_ref?(merge_request.source_branch)
+        # will raise CommandFailed when push fails
+        merge_repo.git.push({raise: true, timeout: true}, :origin, ":#{merge_request.source_branch}")
+      end
+
+      # merge, push and branch removal successful
+      true
+    end
+  end
+rescue Grit::Git::CommandFailed => ex
+  Gitlab::GitLogger.error(ex.message)
+  false
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Satellite/Satellite.html b/doc/code/classes/Gitlab/Satellite/Satellite.html new file mode 100644 index 00000000000..86d82e6ab33 --- /dev/null +++ b/doc/code/classes/Gitlab/Satellite/Satellite.html @@ -0,0 +1,506 @@ + + + + + Gitlab::Satellite::Satellite + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
C
+
+ +
+ +
E
+
+ +
+ +
L
+
+ +
+ +
N
+
+
    + + +
  • + new +
  • + +
+
+ +
P
+
+
    + + +
  • + path +
  • + +
+
+ +
R
+
+
    + + +
  • + repo +
  • + +
+
+ +
+ + + + + + + + + + + + + + +
Constants
+ + + + + + + + + + + + + + +
PARKING_BRANCH="__parking_branch"
 
+ + + + + +
Attributes
+ + + + + + + + +
+ [RW] + project
+ + + + + +
Class Public methods
+ +
+
+ + new(project) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/satellite.rb, line 8
+def initialize(project)
+  @project = project
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + clear_and_update!() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/satellite.rb, line 12
+def clear_and_update!
+  raise "Satellite doesn't exist" unless exists?
+
+  delete_heads!
+  clear_working_dir!
+  update_from_source!
+end
+
+
+ +
+ +
+
+ + create() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/satellite.rb, line 20
+def create
+  create_cmd = "git clone #{project.url_to_repo} #{path}"
+  if system(create_cmd)
+    true
+  else
+    Gitlab::GitLogger.error("Failed to create satellite for #{project.name_with_namespace}")
+    false
+  end
+end
+
+
+ +
+ +
+
+ + exists?() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/satellite.rb, line 30
+def exists?
+  File.exists? path
+end
+
+
+ +
+ +
+
+ + lock() + + +
+ + +
+
  • +

    Locks the satellite

    +
  • +

    Changes the current directory to the satellite’s working dir

    +
  • +

    Yields

    +
+
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/satellite.rb, line 37
+def lock
+  raise "Satellite doesn't exist" unless exists?
+
+  File.open(lock_file, "w+") do |f|
+    f.flock(File::LOCK_EX)
+
+    Dir.chdir(path) do
+      return yield
+    end
+  end
+end
+
+
+ +
+ +
+
+ + lock_file() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/satellite.rb, line 49
+def lock_file
+  Rails.root.join("tmp", "satellite_#{project.id}.lock")
+end
+
+
+ +
+ +
+
+ + path() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/satellite.rb, line 53
+def path
+  Rails.root.join("tmp", "repo_satellites", project.path_with_namespace)
+end
+
+
+ +
+ +
+
+ + repo() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/satellite/satellite.rb, line 57
+def repo
+  raise "Satellite doesn't exist" unless exists?
+
+  @repo ||= Grit::Repo.new(path)
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Seeder.html b/doc/code/classes/Gitlab/Seeder.html new file mode 100644 index 00000000000..a62c96a5526 --- /dev/null +++ b/doc/code/classes/Gitlab/Seeder.html @@ -0,0 +1,134 @@ + + + + + Gitlab::Seeder + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
Q
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
Class Public methods
+ +
+
+ + quiet() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/seeder.rb, line 3
+def self.quiet
+  SeedFu.quiet = true
+  yield
+  SeedFu.quiet = false
+  puts "\nOK".green
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Session.html b/doc/code/classes/Gitlab/Session.html new file mode 100644 index 00000000000..ad14adc0d50 --- /dev/null +++ b/doc/code/classes/Gitlab/Session.html @@ -0,0 +1,82 @@ + + + + + Gitlab::Session + + + + + + + + + + + + + +
+
+ +
+ +

Users API

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Theme.html b/doc/code/classes/Gitlab/Theme.html new file mode 100644 index 00000000000..8f918b35ce4 --- /dev/null +++ b/doc/code/classes/Gitlab/Theme.html @@ -0,0 +1,141 @@ + + + + + Gitlab::Theme + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
C
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
Class Public methods
+ +
+
+ + css_class_by_id(id) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File lib/gitlab/theme.rb, line 3
+def self.css_class_by_id(id)
+  themes = {
+    1 => "ui_basic",
+    2 => "ui_mars",
+    3 => "ui_modern",
+    4 => "ui_gray",
+    5 => "ui_color"
+  }
+
+  id ||= 1
+
+  return themes[id]
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file diff --git a/doc/code/classes/Gitlab/Users.html b/doc/code/classes/Gitlab/Users.html new file mode 100644 index 00000000000..50ba3131240 --- /dev/null +++ b/doc/code/classes/Gitlab/Users.html @@ -0,0 +1,82 @@ + + + + + Gitlab::Users + + + + + + + + + + + + + +
+
+ +
+ +

Users API

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + \ No newline at end of file -- cgit v1.2.1