From 1ea0dd0ffc37232d27f4fa1350af6ebb3b5439f2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 25 Oct 2012 11:59:41 +0300 Subject: App docs --- doc/app/Gitlab/API.html | 452 ++++++++++++ doc/app/Gitlab/APIHelpers.html | 846 +++++++++++++++++++++++ doc/app/Gitlab/AppLogger.html | 523 ++++++++++++++ doc/app/Gitlab/Auth.html | 630 +++++++++++++++++ doc/app/Gitlab/Encode.html | 537 +++++++++++++++ doc/app/Gitlab/Entities.html | 433 ++++++++++++ doc/app/Gitlab/Entities/Hook.html | 439 ++++++++++++ doc/app/Gitlab/Entities/Issue.html | 439 ++++++++++++ doc/app/Gitlab/Entities/Milestone.html | 439 ++++++++++++ doc/app/Gitlab/Entities/Project.html | 439 ++++++++++++ doc/app/Gitlab/Entities/ProjectMember.html | 439 ++++++++++++ doc/app/Gitlab/Entities/ProjectSnippet.html | 439 ++++++++++++ doc/app/Gitlab/Entities/RepoCommit.html | 439 ++++++++++++ doc/app/Gitlab/Entities/RepoObject.html | 439 ++++++++++++ doc/app/Gitlab/Entities/SSHKey.html | 439 ++++++++++++ doc/app/Gitlab/Entities/User.html | 439 ++++++++++++ doc/app/Gitlab/Entities/UserBasic.html | 439 ++++++++++++ doc/app/Gitlab/Entities/UserLogin.html | 439 ++++++++++++ doc/app/Gitlab/FileEditor.html | 647 +++++++++++++++++ doc/app/Gitlab/GitLogger.html | 523 ++++++++++++++ doc/app/Gitlab/Gitolite.html | 716 +++++++++++++++++++ doc/app/Gitlab/Gitolite/AccessDenied.html | 439 ++++++++++++ doc/app/Gitlab/GitoliteConfig.html | 994 +++++++++++++++++++++++++++ doc/app/Gitlab/GitoliteConfig/PullError.html | 439 ++++++++++++ doc/app/Gitlab/GitoliteConfig/PushError.html | 439 ++++++++++++ doc/app/Gitlab/GraphCommit.html | 967 ++++++++++++++++++++++++++ doc/app/Gitlab/InlineDiff.html | 611 ++++++++++++++++ doc/app/Gitlab/Issues.html | 441 ++++++++++++ doc/app/Gitlab/Logger.html | 583 ++++++++++++++++ doc/app/Gitlab/Markdown.html | 580 ++++++++++++++++ doc/app/Gitlab/Merge.html | 628 +++++++++++++++++ doc/app/Gitlab/Milestones.html | 441 ++++++++++++ doc/app/Gitlab/Projects.html | 441 ++++++++++++ doc/app/Gitlab/Satellite.html | 664 ++++++++++++++++++ doc/app/Gitlab/Session.html | 441 ++++++++++++ doc/app/Gitlab/Theme.html | 493 +++++++++++++ doc/app/Gitlab/Users.html | 441 ++++++++++++ 37 files changed, 19617 insertions(+) create mode 100644 doc/app/Gitlab/API.html create mode 100644 doc/app/Gitlab/APIHelpers.html create mode 100644 doc/app/Gitlab/AppLogger.html create mode 100644 doc/app/Gitlab/Auth.html create mode 100644 doc/app/Gitlab/Encode.html create mode 100644 doc/app/Gitlab/Entities.html create mode 100644 doc/app/Gitlab/Entities/Hook.html create mode 100644 doc/app/Gitlab/Entities/Issue.html create mode 100644 doc/app/Gitlab/Entities/Milestone.html create mode 100644 doc/app/Gitlab/Entities/Project.html create mode 100644 doc/app/Gitlab/Entities/ProjectMember.html create mode 100644 doc/app/Gitlab/Entities/ProjectSnippet.html create mode 100644 doc/app/Gitlab/Entities/RepoCommit.html create mode 100644 doc/app/Gitlab/Entities/RepoObject.html create mode 100644 doc/app/Gitlab/Entities/SSHKey.html create mode 100644 doc/app/Gitlab/Entities/User.html create mode 100644 doc/app/Gitlab/Entities/UserBasic.html create mode 100644 doc/app/Gitlab/Entities/UserLogin.html create mode 100644 doc/app/Gitlab/FileEditor.html create mode 100644 doc/app/Gitlab/GitLogger.html create mode 100644 doc/app/Gitlab/Gitolite.html create mode 100644 doc/app/Gitlab/Gitolite/AccessDenied.html create mode 100644 doc/app/Gitlab/GitoliteConfig.html create mode 100644 doc/app/Gitlab/GitoliteConfig/PullError.html create mode 100644 doc/app/Gitlab/GitoliteConfig/PushError.html create mode 100644 doc/app/Gitlab/GraphCommit.html create mode 100644 doc/app/Gitlab/InlineDiff.html create mode 100644 doc/app/Gitlab/Issues.html create mode 100644 doc/app/Gitlab/Logger.html create mode 100644 doc/app/Gitlab/Markdown.html create mode 100644 doc/app/Gitlab/Merge.html create mode 100644 doc/app/Gitlab/Milestones.html create mode 100644 doc/app/Gitlab/Projects.html create mode 100644 doc/app/Gitlab/Satellite.html create mode 100644 doc/app/Gitlab/Session.html create mode 100644 doc/app/Gitlab/Theme.html create mode 100644 doc/app/Gitlab/Users.html (limited to 'doc/app/Gitlab') diff --git a/doc/app/Gitlab/API.html b/doc/app/Gitlab/API.html new file mode 100644 index 00000000000..8fad1eecafc --- /dev/null +++ b/doc/app/Gitlab/API.html @@ -0,0 +1,452 @@ + + + + + + +class Gitlab::API - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::API

+ +
+ +
+ + + + +
+ + + + + + +
+

Constants

+
+ +
VERSION + +
+ + +
+
+ + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/APIHelpers.html b/doc/app/Gitlab/APIHelpers.html new file mode 100644 index 00000000000..47bf3fb193d --- /dev/null +++ b/doc/app/Gitlab/APIHelpers.html @@ -0,0 +1,846 @@ + + + + + + +module Gitlab::APIHelpers - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module Gitlab::APIHelpers

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ attributes_for_keys(keys) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 35
+def attributes_for_keys(keys)
+  attrs = {}
+  keys.each do |key|
+    attrs[key] = params[key] if params[key].present?
+  end
+  attrs
+end
+
+ +
+ + + + +
+ + +
+ +
+ authenticate!() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 21
+def authenticate!
+  unauthorized! unless current_user
+end
+
+ +
+ + + + +
+ + +
+ +
+ authenticated_as_admin!() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 25
+def authenticated_as_admin!
+  forbidden! unless current_user.is_admin?
+end
+
+ +
+ + + + +
+ + +
+ +
+ authorize!(action, subject) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 29
+def authorize! action, subject
+  unless abilities.allowed?(current_user, action, subject)
+    forbidden!
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ current_user() + click to toggle source +
+ + +
+ + + + + +
+
# 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
+
+ +
+ + + + +
+ + +
+ +
+ forbidden!() + click to toggle source +
+ + +
+ +

error helpers

+ + + +
+
# File lib/api/helpers.rb, line 45
+def forbidden!
+  render_api_error!('403 Forbidden', 403)
+end
+
+ +
+ + + + +
+ + +
+ +
+ not_allowed!() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 60
+def not_allowed!
+  render_api_error!('Method Not Allowed', 405)
+end
+
+ +
+ + + + +
+ + +
+ +
+ not_found!(resource = nil) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 49
+def not_found!(resource = nil)
+  message = ["404"]
+  message << resource if resource
+  message << "Not Found"
+  render_api_error!(message.join(' '), 404)
+end
+
+ +
+ + + + +
+ + +
+ +
+ paginate(object) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 17
+def paginate(object)
+  object.page(params[:page]).per(params[:per_page].to_i)
+end
+
+ +
+ + + + +
+ + +
+ +
+ render_api_error!(message, status) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 64
+def render_api_error!(message, status)
+  error!({'message' => message}, status)
+end
+
+ +
+ + + + +
+ + +
+ +
+ unauthorized!() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 56
+def unauthorized!
+  render_api_error!('401 Unauthorized', 401)
+end
+
+ +
+ + + + +
+ + +
+ +
+ user_project() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/api/helpers.rb, line 7
+def user_project
+  if @project ||= current_user.projects.find_by_id(params[:id]) ||
+                  current_user.projects.find_by_code(params[:id])
+  else
+    not_found!
+  end
+
+  @project
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/AppLogger.html b/doc/app/Gitlab/AppLogger.html new file mode 100644 index 00000000000..e3a352af70f --- /dev/null +++ b/doc/app/Gitlab/AppLogger.html @@ -0,0 +1,523 @@ + + + + + + +class Gitlab::AppLogger - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::AppLogger

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ file_name() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/app_logger.rb, line 3
+def self.file_name
+  'application.log'
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ format_message(severity, timestamp, progname, msg) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/app_logger.rb, line 7
+def format_message(severity, timestamp, progname, msg)
+  "#{timestamp.to_s(:long)}: #{msg}\n"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Auth.html b/doc/app/Gitlab/Auth.html new file mode 100644 index 00000000000..ac4fd556a79 --- /dev/null +++ b/doc/app/Gitlab/Auth.html @@ -0,0 +1,630 @@ + + + + + + +class Gitlab::Auth - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Auth

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ create_from_omniauth(auth, ldap = false) + click to toggle source +
+ + +
+ + + + + +
+
# 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,
+    email: email,
+    password: password,
+    password_confirmation: password,
+    projects_limit: Gitlab.config.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) + click to toggle source +
+ + +
+ + + + + +
+
# 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) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/auth.rb, line 49
+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() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/auth.rb, line 66
+def log
+  Gitlab::AppLogger
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Encode.html b/doc/app/Gitlab/Encode.html new file mode 100644 index 00000000000..387e0db22e0 --- /dev/null +++ b/doc/app/Gitlab/Encode.html @@ -0,0 +1,537 @@ + + + + + + +module Gitlab::Encode - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module Gitlab::Encode

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ detect_encoding(message) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/encode.rb, line 34
+def detect_encoding message
+  return nil unless message
+
+  hash = CharlockHolmes::EncodingDetector.detect(message) rescue {}
+  return hash[:encoding] ? hash[:encoding] : nil
+end
+
+ +
+ + + + +
+ + +
+ +
+ utf8(message) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/encode.rb, line 7
+def utf8 message
+  # return nil if message is nil
+  return nil unless message
+
+  message.force_encoding("utf-8")
+  # return message if message type is binary
+  detect = CharlockHolmes::EncodingDetector.detect(message)
+  return message if detect[:type] == :binary
+
+  # if message is utf-8 encoding, just return it
+  return message if message.valid_encoding?
+
+  # if message is not utf-8 encoding, convert it
+  if detect[:encoding]
+    message.force_encoding(detect[:encoding])
+    message.encode!("utf-8", detect[:encoding], undef: :replace, replace: "", invalid: :replace)
+  end
+
+  # ensure message encoding is utf8
+  message.valid_encoding? ? message : raise
+
+# Prevent app from crash cause of encoding errors
+rescue
+  encoding = detect ? detect[:encoding] : "unknown"
+  "--broken encoding: #{encoding}"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities.html b/doc/app/Gitlab/Entities.html new file mode 100644 index 00000000000..8cd0d837ed9 --- /dev/null +++ b/doc/app/Gitlab/Entities.html @@ -0,0 +1,433 @@ + + + + + + +module Gitlab::Entities - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module Gitlab::Entities

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/Hook.html b/doc/app/Gitlab/Entities/Hook.html new file mode 100644 index 00000000000..c9eba832bc8 --- /dev/null +++ b/doc/app/Gitlab/Entities/Hook.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::Hook - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::Hook

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/Issue.html b/doc/app/Gitlab/Entities/Issue.html new file mode 100644 index 00000000000..f713b7ab609 --- /dev/null +++ b/doc/app/Gitlab/Entities/Issue.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::Issue - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::Issue

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/Milestone.html b/doc/app/Gitlab/Entities/Milestone.html new file mode 100644 index 00000000000..f762ad29227 --- /dev/null +++ b/doc/app/Gitlab/Entities/Milestone.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::Milestone - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::Milestone

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/Project.html b/doc/app/Gitlab/Entities/Project.html new file mode 100644 index 00000000000..725e6b75d49 --- /dev/null +++ b/doc/app/Gitlab/Entities/Project.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::Project - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::Project

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/ProjectMember.html b/doc/app/Gitlab/Entities/ProjectMember.html new file mode 100644 index 00000000000..468d3dc1ac9 --- /dev/null +++ b/doc/app/Gitlab/Entities/ProjectMember.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::ProjectMember - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::ProjectMember

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/ProjectSnippet.html b/doc/app/Gitlab/Entities/ProjectSnippet.html new file mode 100644 index 00000000000..e19fad759ac --- /dev/null +++ b/doc/app/Gitlab/Entities/ProjectSnippet.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::ProjectSnippet - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::ProjectSnippet

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/RepoCommit.html b/doc/app/Gitlab/Entities/RepoCommit.html new file mode 100644 index 00000000000..04c118a3f9c --- /dev/null +++ b/doc/app/Gitlab/Entities/RepoCommit.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::RepoCommit - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::RepoCommit

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/RepoObject.html b/doc/app/Gitlab/Entities/RepoObject.html new file mode 100644 index 00000000000..27f928c1b8e --- /dev/null +++ b/doc/app/Gitlab/Entities/RepoObject.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::RepoObject - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::RepoObject

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/SSHKey.html b/doc/app/Gitlab/Entities/SSHKey.html new file mode 100644 index 00000000000..43ed0f01dcf --- /dev/null +++ b/doc/app/Gitlab/Entities/SSHKey.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::SSHKey - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::SSHKey

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/User.html b/doc/app/Gitlab/Entities/User.html new file mode 100644 index 00000000000..fb978194084 --- /dev/null +++ b/doc/app/Gitlab/Entities/User.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::User - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::User

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/UserBasic.html b/doc/app/Gitlab/Entities/UserBasic.html new file mode 100644 index 00000000000..dcb1e78209d --- /dev/null +++ b/doc/app/Gitlab/Entities/UserBasic.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::UserBasic - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::UserBasic

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Entities/UserLogin.html b/doc/app/Gitlab/Entities/UserLogin.html new file mode 100644 index 00000000000..fde77335268 --- /dev/null +++ b/doc/app/Gitlab/Entities/UserLogin.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Entities::UserLogin - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Entities::UserLogin

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/FileEditor.html b/doc/app/Gitlab/FileEditor.html new file mode 100644 index 00000000000..0916d63cbe0 --- /dev/null +++ b/doc/app/Gitlab/FileEditor.html @@ -0,0 +1,647 @@ + + + + + + +class Gitlab::FileEditor - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::FileEditor

+ +
+ +

GitLab file editor

+ +

It gives you ability to make changes to files & commit this changes +from GitLab UI.

+ +
+ + + + +
+ + + + + + + + +
+

Attributes

+ + +
+
+ project[RW] +
+ +
+ + + +
+
+ +
+
+ ref[RW] +
+ +
+ + + +
+
+ +
+
+ user[RW] +
+ +
+ + + +
+
+ +
+ + + + +
+

Public Class Methods

+ + +
+ +
+ new(user, project, ref) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/file_editor.rb, line 9
+def initialize(user, project, ref)
+  self.user = user
+  self.project = project
+  self.ref = ref
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ update(path, content, commit_message, last_commit) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/file_editor.rb, line 15
+def update(path, content, commit_message, last_commit)
+  return false unless can_edit?(path, last_commit)
+
+  Grit::Git.with_timeout(10.seconds) do
+    lock_file = Rails.root.join("tmp", "#{project.path}.lock")
+
+    File.open(lock_file, "w+") do |f|
+      f.flock(File::LOCK_EX)
+
+      unless project.satellite.exists?
+        raise "Satellite doesn't exist"
+      end
+
+      project.satellite.clear
+
+      Dir.chdir(project.satellite.path) do
+        r = Grit::Repo.new('.')
+        r.git.sh "git reset --hard"
+        r.git.sh "git fetch origin"
+        r.git.sh "git config user.name \"#{user.name}\""
+        r.git.sh "git config user.email \"#{user.email}\""
+        r.git.sh "git checkout -b #{ref} origin/#{ref}"
+        File.open(path, 'w'){|f| f.write(content)}
+        r.git.sh "git add ."
+        r.git.sh "git commit -am '#{commit_message}'"
+        output = r.git.sh "git push origin #{ref}"
+
+        if output =~ %rreject/
+          return false
+        end
+      end
+    end
+  end
+  true
+end
+
+ +
+ + + + +
+ + +
+ +
+

Protected Instance Methods

+ + +
+ +
+ can_edit?(path, last_commit) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/file_editor.rb, line 53
+def can_edit?(path, last_commit)
+  current_last_commit = @project.last_commit_for(ref, path).sha
+  last_commit == current_last_commit
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/GitLogger.html b/doc/app/Gitlab/GitLogger.html new file mode 100644 index 00000000000..c37bce98ca5 --- /dev/null +++ b/doc/app/Gitlab/GitLogger.html @@ -0,0 +1,523 @@ + + + + + + +class Gitlab::GitLogger - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::GitLogger

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ file_name() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/git_logger.rb, line 3
+def self.file_name
+  'githost.log'
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ format_message(severity, timestamp, progname, msg) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/git_logger.rb, line 7
+def format_message(severity, timestamp, progname, msg)
+  "#{timestamp.to_s(:long)} -> #{severity} -> #{msg}\n"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Gitolite.html b/doc/app/Gitlab/Gitolite.html new file mode 100644 index 00000000000..60ef3b136e5 --- /dev/null +++ b/doc/app/Gitlab/Gitolite.html @@ -0,0 +1,716 @@ + + + + + + +class Gitlab::Gitolite - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Gitolite

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Instance Methods

+ + +
+ +
+ config() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite.rb, line 7
+def config
+  Gitlab::GitoliteConfig.new
+end
+
+ +
+ + + + +
+ + +
+ +
+ create_repository(project) + click to toggle source +
+ + +
+ + + + + +
+ + + + +
+ Alias for: update_repository +
+ +
+ + +
+ +
+ enable_automerge() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite.rb, line 37
+def enable_automerge
+  config.admin_all_repo!
+end
+
+ +
+ + + + +
+ + +
+ +
+ remove_key(key_id, projects) + click to toggle source +
+ + +
+ + + + + +
+
# 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) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite.rb, line 29
+def remove_repository project
+  config.destroy_project!(project)
+end
+
+ +
+ + + + +
+ + +
+ +
+ set_key(key_id, key_content, projects) + click to toggle source +
+ + +
+ + + + + +
+
# 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_repository(project) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite.rb, line 25
+def update_repository project
+  config.update_project!(project.path, project)
+end
+
+ +
+ + +
+ Also aliased as: create_repository +
+ + + +
+ + +
+ +
+ url_to_repo(path) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite.rb, line 33
+def url_to_repo path
+  Gitlab.config.ssh_path + "#{path}.git"
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Gitolite/AccessDenied.html b/doc/app/Gitlab/Gitolite/AccessDenied.html new file mode 100644 index 00000000000..64a3b17a30f --- /dev/null +++ b/doc/app/Gitlab/Gitolite/AccessDenied.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::Gitolite::AccessDenied - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Gitolite::AccessDenied

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/GitoliteConfig.html b/doc/app/Gitlab/GitoliteConfig.html new file mode 100644 index 00000000000..19671089b15 --- /dev/null +++ b/doc/app/Gitlab/GitoliteConfig.html @@ -0,0 +1,994 @@ + + + + + + +class Gitlab::GitoliteConfig - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::GitoliteConfig

+ +
+ +
+ + + + +
+ + + + + + + + +
+

Attributes

+ + +
+
+ conf[R] +
+ +
+ + + +
+
+ +
+
+ config_tmp_dir[R] +
+ +
+ + + +
+
+ +
+
+ ga_repo[R] +
+ +
+ + + +
+
+ +
+ + + + +
+

Public Instance Methods

+ + +
+ +
+ admin_all_repo() + click to toggle source +
+ + +
+ +

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

+ + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 162
+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!() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 177
+def admin_all_repo!
+  apply { |config| config.admin_all_repo }
+end
+
+ +
+ + + + +
+ + +
+ +
+ apply() { |self| ... } + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 20
+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
+
+ +
+ + + + +
+ + +
+ +
+ destroy_project(project) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 81
+def destroy_project(project)
+  FileUtils.rm_rf(project.path_to_repo)
+  conf.rm_repo(project.path)
+end
+
+ +
+ + + + +
+ + +
+ +
+ destroy_project!(project) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 86
+def destroy_project!(project)
+  apply do |config|
+    config.destroy_project(project)
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ log(message) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 77
+def log message
+  Gitlab::GitLogger.error(message)
+end
+
+ +
+ + + + +
+ + +
+ +
+ rm_key(user) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 98
+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(repo_name, project) + click to toggle source +
+ + +
+ +

update or create

+ + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 105
+def update_project(repo_name, project)
+  repo = update_project_config(project, conf)
+  conf.add_repo(repo, true)
+end
+
+ +
+ + + + +
+ + +
+ +
+ update_project!(repo_name, project) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 110
+def update_project!(repo_name, project)
+  apply do |config|
+    config.update_project(repo_name, project)
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ update_project_config(project, conf) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 125
+def update_project_config(project, conf)
+  repo_name = project.path
+
+  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) + click to toggle source +
+ + +
+ +

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

+ + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 118
+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) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/backend/gitolite_config.rb, line 92
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/GitoliteConfig/PullError.html b/doc/app/Gitlab/GitoliteConfig/PullError.html new file mode 100644 index 00000000000..8e5a1510d45 --- /dev/null +++ b/doc/app/Gitlab/GitoliteConfig/PullError.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::GitoliteConfig::PullError - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::GitoliteConfig::PullError

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/GitoliteConfig/PushError.html b/doc/app/Gitlab/GitoliteConfig/PushError.html new file mode 100644 index 00000000000..c1541f49d66 --- /dev/null +++ b/doc/app/Gitlab/GitoliteConfig/PushError.html @@ -0,0 +1,439 @@ + + + + + + +class Gitlab::GitoliteConfig::PushError - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::GitoliteConfig::PushError

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/GraphCommit.html b/doc/app/Gitlab/GraphCommit.html new file mode 100644 index 00000000000..b8ffa6f4161 --- /dev/null +++ b/doc/app/Gitlab/GraphCommit.html @@ -0,0 +1,967 @@ + + + + + + +class Gitlab::GraphCommit - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::GraphCommit

+ +
+ +
+ + + + +
+ + + + + + + + +
+

Attributes

+ + +
+
+ refs[RW] +
+ +
+ + + +
+
+ +
+
+ space[RW] +
+ +
+ + + +
+
+ +
+
+ time[RW] +
+ +
+ + + +
+
+ +
+ + + + +
+

Public Class Methods

+ + +
+ +
+ find_free_space(time_range) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/graph_commit.rb, line 113
+def self.find_free_space(time_range)
+  reserved = []
+  for day in time_range
+      reserved += @_reserved[day]
+  end
+  space = 1
+  while reserved.include? space do
+    space += 1
+  end
+  space
+end
+
+ +
+ + + + +
+ + +
+ +
+ index_commits(commits) + click to toggle source +
+ + +
+ +

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<GraphCommit>] comits to index

+ +

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

+ + + +
+
# File lib/gitlab/graph_commit.rb, line 33
+def self.index_commits(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) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/graph_commit.rb, line 107
+def self.mark_reserved(time_range, space)
+  for day in time_range
+    @_reserved[day].push(space)
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ new(commit) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/graph_commit.rb, line 148
+def initialize(commit)
+  @_commit = commit
+  @time = -1
+  @space = 0
+end
+
+ +
+ + + + +
+ + +
+ +
+ place_chain(commit, map, parent_time = nil) + click to toggle source +
+ + +
+ +

Add space mark on commit and its parents

+ +

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

+ + + +
+
# File lib/gitlab/graph_commit.rb, line 73
+def self.place_chain(commit, map, parent_time = nil)
+  leaves = take_left_leaves(commit, map)
+  if leaves.empty? then
+    return
+  end
+  space = find_free_space(leaves.last.time..leaves.first.time)
+  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 then
+      parent = map[p.id]
+      if parent.time < min_time then
+        min_time = parent.time
+      end
+    end
+  end
+  if parent_time.nil? then
+    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 == 0}
+    for p in parents
+      place_chain(map[p.id], map, l.time)
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ take_left_leaves(commit, map) + click to toggle source +
+ + +
+ +

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

+ +

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

+ +

@return [Array<GraphCommit>] list of branch commits

+ + + +
+
# File lib/gitlab/graph_commit.rb, line 132
+def self.take_left_leaves(commit, map)
+  leaves = []
+  leaves.push(commit)  if commit.space == 0
+  while true
+    parent = commit.parents.collect
+      .select{|p| map.include? p.id and map[p.id].space == 0}
+    if parent.count == 0 then
+      return leaves
+    else
+      commit = map[parent.first.id]
+      leaves.push(commit)
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ to_graph(project) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/graph_commit.rb, line 10
+def self.to_graph(project)
+  @repo = project.repo
+  commits = Grit::Commit.find_all(@repo, nil, {max_count: 650})
+
+  ref_cache = {}
+
+  commits.map! {|c| GraphCommit.new(Commit.new(c))}
+  commits.each { |commit| commit.add_refs(ref_cache, @repo) }
+
+  days = GraphCommit.index_commits(commits)
+  @days_json = days.compact.collect{|d| [d.day, d.strftime("%b")] }.to_json
+  @commits_json = commits.map(&:to_graph_hash).to_json
+
+  return @days_json, @commits_json
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ add_refs(ref_cache, repo) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/graph_commit.rb, line 174
+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) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/graph_commit.rb, line 154
+def method_missing(m, *args, &block)
+  @_commit.send(m, *args, &block)
+end
+
+ +
+ + + + +
+ + +
+ +
+ to_graph_hash() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/graph_commit.rb, line 158
+def to_graph_hash
+  h = {}
+  h[:parents] = self.parents.collect do |p|
+    [p.id,0,0]
+  end
+  h[:author]  = Gitlab::Encode.utf8(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] = escape_once(Gitlab::Encode.utf8(message))
+  h[:login]   = author.email
+  h
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/InlineDiff.html b/doc/app/Gitlab/InlineDiff.html new file mode 100644 index 00000000000..91eeae9c441 --- /dev/null +++ b/doc/app/Gitlab/InlineDiff.html @@ -0,0 +1,611 @@ + + + + + + +class Gitlab::InlineDiff - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::InlineDiff

+ +
+ +
+ + + + +
+ + + + + + +
+

Constants

+
+ +
FINISH + +
+ + +
START + +
+ + +
+
+ + + + + + +
+

Public Class Methods

+ + +
+ +
+ _indexes_of_changed_lines(diff_arr) + click to toggle source +
+ + +
+ + + + + +
+
# 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) + click to toggle source +
+ + +
+ + + + + +
+
# 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) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/inline_diff.rb, line 58
+def replace_markers line
+  line.gsub!(START, "<span class='idiff'>")
+  line.gsub!(FINISH, "</span>")
+  line
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Issues.html b/doc/app/Gitlab/Issues.html new file mode 100644 index 00000000000..eda99ed10dc --- /dev/null +++ b/doc/app/Gitlab/Issues.html @@ -0,0 +1,441 @@ + + + + + + +class Gitlab::Issues - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Issues

+ +
+ +

Issues API

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Logger.html b/doc/app/Gitlab/Logger.html new file mode 100644 index 00000000000..8cc6cdea81b --- /dev/null +++ b/doc/app/Gitlab/Logger.html @@ -0,0 +1,583 @@ + + + + + + +class Gitlab::Logger - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Logger

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ build() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/logger.rb, line 17
+def self.build
+  new(Rails.root.join("log", file_name))
+end
+
+ +
+ + + + +
+ + +
+ +
+ error(message) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/logger.rb, line 3
+def self.error(message)
+  build.error(message)
+end
+
+ +
+ + + + +
+ + +
+ +
+ info(message) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/logger.rb, line 7
+def self.info(message)
+  build.info(message)
+end
+
+ +
+ + + + +
+ + +
+ +
+ read_latest() + click to toggle source +
+ + +
+ + + + + +
+
# 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 = File.read(path).split("\n")
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Markdown.html b/doc/app/Gitlab/Markdown.html new file mode 100644 index 00000000000..12691455600 --- /dev/null +++ b/doc/app/Gitlab/Markdown.html @@ -0,0 +1,580 @@ + + + + + + +module Gitlab::Markdown - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

module 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:\" />
+
+ +
+ + + + +
+ + + + + + +
+

Constants

+
+ +
EMOJI_PATTERN + +
+ + +
REFERENCE_PATTERN + +
+ + +
+
+ + + + +
+

Attributes

+ + +
+
+ html_options[R] +
+ +
+ + + +
+
+ +
+ + + + +
+

Public Instance Methods

+ + +
+ +
+ gfm(text, html_options = {}) + click to toggle source +
+ + +
+ +

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 48
+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
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Merge.html b/doc/app/Gitlab/Merge.html new file mode 100644 index 00000000000..99a66cd53bb --- /dev/null +++ b/doc/app/Gitlab/Merge.html @@ -0,0 +1,628 @@ + + + + + + +class Gitlab::Merge - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Merge

+ +
+ +
+ + + + +
+ + + + + + + + +
+

Attributes

+ + +
+
+ merge_request[RW] +
+ +
+ + + +
+
+ +
+
+ project[RW] +
+ +
+ + + +
+
+ +
+
+ user[RW] +
+ +
+ + + +
+
+ +
+ + + + +
+

Public Class Methods

+ + +
+ +
+ new(merge_request, user) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/merge.rb, line 5
+def initialize(merge_request, user)
+  @merge_request = merge_request
+  @project = merge_request.project
+  @user = user
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ can_be_merged?() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/merge.rb, line 11
+def can_be_merged?
+  in_locked_and_timed_satellite do |merge_repo|
+    merge_in_satellite!(merge_repo)
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ merge!() + click to toggle source +
+ + +
+ +

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 satallite to Gitolite failed or was +rejected Returns true otherwise

+ + + +
+
# File lib/gitlab/merge.rb, line 24
+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}, :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}, :origin, ":#{merge_request.source_branch}")
+      end
+
+      # merge, push and branch removal successful
+      true
+    end
+  end
+rescue Grit::Git::CommandFailed
+  false
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Milestones.html b/doc/app/Gitlab/Milestones.html new file mode 100644 index 00000000000..aac605b2896 --- /dev/null +++ b/doc/app/Gitlab/Milestones.html @@ -0,0 +1,441 @@ + + + + + + +class Gitlab::Milestones - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Milestones

+ +
+ +

Milestones API

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Projects.html b/doc/app/Gitlab/Projects.html new file mode 100644 index 00000000000..a44cba3c7c6 --- /dev/null +++ b/doc/app/Gitlab/Projects.html @@ -0,0 +1,441 @@ + + + + + + +class Gitlab::Projects - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Projects

+ +
+ +

Projects API

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Satellite.html b/doc/app/Gitlab/Satellite.html new file mode 100644 index 00000000000..4615d1c67c2 --- /dev/null +++ b/doc/app/Gitlab/Satellite.html @@ -0,0 +1,664 @@ + + + + + + +class Gitlab::Satellite - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Satellite

+ +
+ +
+ + + + +
+ + + + + + +
+

Constants

+
+ +
PARKING_BRANCH + +
+ + +
+
+ + + + +
+

Attributes

+ + +
+
+ project[RW] +
+ +
+ + + +
+
+ +
+ + + + +
+

Public Class Methods

+ + +
+ +
+ new(project) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/satellite.rb, line 8
+def initialize project
+  self.project = project
+end
+
+ +
+ + + + +
+ + +
+ +
+

Public Instance Methods

+ + +
+ +
+ clear() + click to toggle source +
+ + +
+ +

will be deleted all branches except PARKING_BRANCH

+ + + +
+
# File lib/gitlab/satellite.rb, line 25
+def clear
+  Dir.chdir(path) do
+    heads = Grit::Repo.new(".").heads.map{|head| head.name}
+    if heads.include? PARKING_BRANCH
+      %xgit checkout #{PARKING_BRANCH}`
+    else
+      %xgit checkout -b #{PARKING_BRANCH}`
+    end
+    heads.delete(PARKING_BRANCH)
+    heads.each do |head|
+      %xgit branch -D #{head}`
+    end
+  end
+end
+
+ +
+ + + + +
+ + +
+ +
+ create() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/satellite.rb, line 12
+def create
+  %xgit clone #{project.url_to_repo} #{path}`
+end
+
+ +
+ + + + +
+ + +
+ +
+ exists?() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/satellite.rb, line 20
+def exists?
+  File.exists? path
+end
+
+ +
+ + + + +
+ + +
+ +
+ path() + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/satellite.rb, line 16
+def path
+  Rails.root.join("tmp", "repo_satellites", project.path)
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Session.html b/doc/app/Gitlab/Session.html new file mode 100644 index 00000000000..12f3433ebfd --- /dev/null +++ b/doc/app/Gitlab/Session.html @@ -0,0 +1,441 @@ + + + + + + +class Gitlab::Session - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Session

+ +
+ +

Users API

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + diff --git a/doc/app/Gitlab/Theme.html b/doc/app/Gitlab/Theme.html new file mode 100644 index 00000000000..00b3e5f6b62 --- /dev/null +++ b/doc/app/Gitlab/Theme.html @@ -0,0 +1,493 @@ + + + + + + +class Gitlab::Theme - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Theme

+ +
+ +
+ + + + +
+ + + + + + + + + + +
+

Public Class Methods

+ + +
+ +
+ css_class_by_id(id) + click to toggle source +
+ + +
+ + + + + +
+
# File lib/gitlab/theme.rb, line 3
+def self.css_class_by_id(id)
+  themes = { 
+    1 => "ui_basic",
+    2 => "ui_mars",
+    3 => "ui_modern"
+  }
+
+  id ||= 1
+
+  return themes[id]
+end
+
+ +
+ + + + +
+ + +
+ +
+ +
+ + + + diff --git a/doc/app/Gitlab/Users.html b/doc/app/Gitlab/Users.html new file mode 100644 index 00000000000..c9712874c65 --- /dev/null +++ b/doc/app/Gitlab/Users.html @@ -0,0 +1,441 @@ + + + + + + +class Gitlab::Users - Rails Application Documentation + + + + + + + + + + + + + + + + +
+

class Gitlab::Users

+ +
+ +

Users API

+ +
+ + + + +
+ + + + + + + + + + +
+ +
+ + + + -- cgit v1.2.1