Skip to content
Snippets Groups Projects
Commit 375caeef authored by Sebastian Ziebell's avatar Sebastian Ziebell
Browse files

Merge branch 'master' into fixes/api

parents ae40e855 b9f8b401
No related branches found
No related tags found
No related merge requests found
Showing
with 81 additions and 35 deletions
Loading
Loading
@@ -20,6 +20,7 @@
.hint { font-style: italic; color: #999; }
.light { color: #888 }
.tiny { font-weight: normal }
.vtop { vertical-align: top; }
 
 
/** ALERT MESSAGES **/
Loading
Loading
Loading
Loading
@@ -7,10 +7,20 @@ class GraphController < ProjectResourceController
before_filter :require_non_empty_project
 
def show
if params.has_key?(:q) && params[:q].blank?
redirect_to project_graph_path(@project, params[:id])
return
end
if params.has_key?(:q)
@q = params[:q]
@commit = @project.repository.commit(@q) || @commit
end
respond_to do |format|
format.html
format.json do
graph = Gitlab::Graph::JsonBuilder.new(project, @ref)
graph = Gitlab::Graph::JsonBuilder.new(project, @ref, @commit)
render :json => graph.to_json
end
end
Loading
Loading
Loading
Loading
@@ -6,7 +6,7 @@ class Public::ProjectsController < ApplicationController
layout 'public'
 
def index
@projects = Project.public
@projects = Project.public_only
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
end
end
class RegistrationsController < Devise::RegistrationsController
before_filter :signup_enabled?
 
def destroy
if current_user.owned_projects.count > 0
redirect_to account_profile_path, alert: "Remove projects and groups before removing account." and return
end
current_user.destroy
respond_to do |format|
format.html { redirect_to new_user_session_path, notice: "Account successfully removed." }
end
end
private
 
def signup_enabled?
Loading
Loading
Loading
Loading
@@ -19,12 +19,12 @@ module Issuable
validates :title, presence: true, length: { within: 0..255 }
validates :closed, inclusion: { in: [true, false] }
 
scope :opened, where(closed: false)
scope :closed, where(closed: true)
scope :opened, -> { where(closed: false) }
scope :closed, -> { where(closed: true) }
scope :of_group, ->(group) { where(project_id: group.project_ids) }
scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) }
scope :assigned, ->(u) { where(assignee_id: u.id)}
scope :recent, order("created_at DESC")
scope :recent, -> { order("created_at DESC") }
 
delegate :name,
:email,
Loading
Loading
Loading
Loading
@@ -42,8 +42,8 @@ class Event < ActiveRecord::Base
serialize :data
 
# Scopes
scope :recent, order("created_at DESC")
scope :code_push, where(action: Pushed)
scope :recent, -> { order("created_at DESC") }
scope :code_push, -> { where(action: Pushed) }
scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent }
 
class << self
Loading
Loading
Loading
Loading
@@ -20,8 +20,8 @@ class Milestone < ActiveRecord::Base
has_many :issues
has_many :merge_requests
 
scope :active, where(closed: false)
scope :closed, where(closed: true)
scope :active, -> { where(closed: false) }
scope :closed, -> { where(closed: true) }
 
validates :title, presence: true
validates :project, presence: true
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ class Namespace < ActiveRecord::Base
after_update :move_dir
after_destroy :rm_dir
 
scope :root, where('type IS NULL')
scope :root, -> { where('type IS NULL') }
 
def self.search query
where("name LIKE :query OR path LIKE :query", query: "%#{query}%")
Loading
Loading
Loading
Loading
@@ -43,8 +43,8 @@ class Note < ActiveRecord::Base
 
# Scopes
scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
scope :inline, where("line_code IS NOT NULL")
scope :not_inline, where("line_code IS NULL")
scope :inline, -> { where("line_code IS NOT NULL") }
scope :not_inline, -> { where("line_code IS NULL") }
 
scope :common, ->{ where(noteable_type: ["", nil]) }
scope :fresh, ->{ order("created_at ASC, id ASC") }
Loading
Loading
Loading
Loading
@@ -91,7 +91,7 @@ class Project < ActiveRecord::Base
scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
scope :public, where(public: true)
scope :public_only, -> { where(public: true) }
 
class << self
def abandoned
Loading
Loading
Loading
Loading
@@ -31,9 +31,9 @@ class Snippet < ActiveRecord::Base
validates :content, presence: true
 
# Scopes
scope :fresh, order("created_at DESC")
scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current])
scope :expired, where(["expires_at IS NOT NULL AND expires_at < ?", Time.current])
scope :fresh, -> { order("created_at DESC") }
scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) }
scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) }
 
def self.content_types
[
Loading
Loading
Loading
Loading
@@ -87,10 +87,10 @@ class User < ActiveRecord::Base
delegate :path, to: :namespace, allow_nil: true, prefix: true
 
# Scopes
scope :admins, where(admin: true)
scope :blocked, where(blocked: true)
scope :active, where(blocked: false)
scope :alphabetically, order('name ASC')
scope :admins, -> { where(admin: true) }
scope :blocked, -> { where(blocked: true) }
scope :active, -> { where(blocked: false) }
scope :alphabetically, -> { order('name ASC') }
scope :in_team, ->(team){ where(id: team.member_ids) }
scope :not_in_team, ->(team){ where('users.id NOT IN (:ids)', ids: team.member_ids) }
scope :potential_team_members, ->(team) { team.members.any? ? active.not_in_team(team) : active }
Loading
Loading
Loading
Loading
@@ -32,10 +32,10 @@ class UsersProject < ActiveRecord::Base
 
delegate :name, :username, :email, to: :user, prefix: true
 
scope :guests, where(project_access: GUEST)
scope :reporters, where(project_access: REPORTER)
scope :developers, where(project_access: DEVELOPER)
scope :masters, where(project_access: MASTER)
scope :guests, -> { where(project_access: GUEST) }
scope :reporters, -> { where(project_access: REPORTER) }
scope :developers, -> { where(project_access: DEVELOPER) }
scope :masters, -> { where(project_access: MASTER) }
 
scope :in_project, ->(project) { where(project_id: project.id) }
scope :in_projects, ->(projects) { where(project_id: project_ids) }
Loading
Loading
Loading
Loading
@@ -11,17 +11,17 @@
.clearfix
= f.label :name
.input
= f.text_field :name, required: true
= f.text_field :name, required: true, autocomplete: "off"
%span.help-inline * required
.clearfix
= f.label :username
.input
= f.text_field :username, required: true
= f.text_field :username, required: true, autocomplete: "off"
%span.help-inline * required
.clearfix
= f.label :email
.input
= f.text_field :email, required: true
= f.text_field :email, required: true, autocomplete: "off"
%span.help-inline * required
 
%fieldset
Loading
Loading
%h3.page_title Project Network Graph
%hr
.clearfix
.pull-left
= render partial: 'shared/ref_switcher', locals: {destination: 'graph', path: @path}
.search.pull-right
= form_tag project_graph_path(@project, params[:id]), method: :get do |f|
.control-group
= label_tag :search , "Looking for commit:", class: 'control-label light'
.controls
= text_field_tag :q, @q, placeholder: "Input SHA", class: "search-input xlarge"
= button_tag type: 'submit', class: 'btn vtop' do
%i.icon-search
%h3.page_title Project Network Graph
%br
= render partial: 'shared/ref_switcher', locals: {destination: 'graph', path: @path}
%br
= render "head"
.graph_holder
%h4
%small You can move around the graph by using the arrow keys.
Loading
Loading
@@ -12,8 +9,9 @@
var branch_graph;
$(function(){
branch_graph = new BranchGraph($("#holder"), {
url: '#{project_graph_path(@project, @ref, format: :json)}',
url: '#{project_graph_path(@project, @ref, q: @q, format: :json)}',
commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}',
ref: '#{@ref}'
ref: '#{@ref}',
commit_id: '#{@commit.id}'
});
});
Loading
Loading
@@ -77,4 +77,10 @@
.input
= f.submit 'Save username', class: "btn btn-save"
 
- if Gitlab.config.gitlab.signup_enabled
%fieldset.remove-account
%legend
Remove account
%small.cred.pull-right
Before removing the account you must remove all projects!
= link_to 'Delete account', user_registration_path, confirm: "REMOVE #{current_user.name}? Are you sure?", method: :delete, class: "btn btn-remove delete-key btn-small pull-right"
\ No newline at end of file
Loading
Loading
@@ -167,12 +167,12 @@ Gitlab::Application.routes.draw do
get "files"
end
 
resources :blob, only: [:show], constraints: {id: /.+/}
resources :tree, only: [:show, :edit, :update], constraints: {id: /.+/}
resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
resources :commits, only: [:show], constraints: {id: /.+/}
resources :compare, only: [:index, :create]
resources :blame, only: [:show], constraints: {id: /.+/}
resources :blob, only: [:show], constraints: {id: /.+/}
resources :graph, only: [:show], constraints: {id: /.+/}
match "/compare/:from...:to" => "compare#show", as: "compare",
:via => [:get, :post], constraints: {from: /.+/, to: /.+/}
Loading
Loading
Loading
Loading
@@ -79,6 +79,9 @@ Parameters:
}
```
 
Will return status code `200` on success or `404 Not found` if the branch is not available.
## Protect a project repository branch
 
Protect a single project repository branch.
Loading
Loading
Loading
Loading
@@ -265,6 +265,7 @@ module Gitlab
# GET /projects/:id/repository/branches/:branch
get ":id/repository/branches/:branch" do
@branch = user_project.repo.heads.find { |item| item.name == params[:branch] }
not_found!("Branch does not exist") if @branch.nil?
present @branch, with: Entities::RepoObject, project: user_project
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment