diff options
author | Florian Unglaub <florian.unglaub@nix-wie-weg.de> | 2012-08-24 15:25:52 +0200 |
---|---|---|
committer | Florian Unglaub <florian.unglaub@nix-wie-weg.de> | 2012-08-24 15:25:52 +0200 |
commit | 48443d20ca9aa10323c1b81835e519680b10debc (patch) | |
tree | 7488eeab446a1a01f90450e50028bfcbdc0ad1d0 /app/models | |
parent | c5ae1549a1d09599734ccaab27e90a8752f1ede6 (diff) | |
parent | 6d4ae75f544d9819954865c105414a722344336a (diff) | |
download | gitlab-ce-48443d20ca9aa10323c1b81835e519680b10debc.tar.gz |
Merge branch 'master' of git://github.com/gitlabhq/gitlabhq
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/issue.rb | 2 | ||||
-rw-r--r-- | app/models/merge_request.rb | 7 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 34 |
4 files changed, 29 insertions, 16 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 454b13586ac..6409eebac63 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -9,8 +9,6 @@ class Issue < ActiveRecord::Base validates :description, length: { within: 0..2000 } - acts_as_list - def self.open_for(user) opened.assigned(user) end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 47966d669f6..542817b0eea 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -88,8 +88,11 @@ class MergeRequest < ActiveRecord::Base end def unmerged_diffs - commits = project.repo.commits_between(target_branch, source_branch).map {|c| Commit.new(c)} - diffs = project.repo.diff(commits.first.prev_commit.id, commits.last.id) rescue [] + # Only show what is new in the source branch compared to the target branch, not the other way around. + # The linex below with merge_base is equivalent to diff with three dots (git diff branch1...branch2) + # From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B" + common_commit = project.repo.git.native(:merge_base, {}, [target_branch, source_branch]).strip + diffs = project.repo.diff(common_commit, source_branch) end def last_commit diff --git a/app/models/project.rb b/app/models/project.rb index 714953c64c7..3fe11916504 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2,7 +2,7 @@ require "grit" class Project < ActiveRecord::Base include Repository - include ProjectPush + include PushObserver include Authority include Team diff --git a/app/models/user.rb b/app/models/user.rb index 92c81c83d41..ad6af6a6dd0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,7 +7,7 @@ class User < ActiveRecord::Base attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :projects_limit, :skype, :linkedin, :twitter, :dark_scheme, - :theme_id, :force_random_password + :theme_id, :force_random_password, :extern_uid, :provider attr_accessor :force_random_password @@ -54,6 +54,8 @@ class User < ActiveRecord::Base validates :bio, length: { within: 0..255 } + validates :extern_uid, :allow_blank => true, :uniqueness => {:scope => :provider} + before_save :ensure_authentication_token alias_attribute :private_token, :authentication_token @@ -84,21 +86,31 @@ class User < ActiveRecord::Base where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)') end - def self.find_for_ldap_auth(omniauth_info) - name = omniauth_info.name.force_encoding("utf-8") - email = omniauth_info.email.downcase unless omniauth_info.email.nil? - raise OmniAuth::Error, "LDAP accounts must provide an email address" if email.nil? + def self.find_for_ldap_auth(auth, signed_in_resource=nil) + uid = auth.info.uid + provider = auth.provider + name = auth.info.name.force_encoding("utf-8") + 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_email(email) + if @user = User.find_by_extern_uid_and_provider(uid, provider) + @user + # workaround for backward compatibility + elsif @user = User.find_by_email(email) + logger.info "Updating legacy LDAP user #{email} with extern_uid => #{uid}" + @user.update_attributes(:extern_uid => uid, :provider => provider) @user else + logger.info "Creating user from LDAP login {uid => #{uid}, name => #{name}, email => #{email}}" password = Devise.friendly_token[0, 8].downcase @user = User.create( - name: name, - email: email, - password: password, - password_confirmation: password, - projects_limit: Gitlab.config.default_projects_limit + :extern_uid => uid, + :provider => provider, + :name => name, + :email => email, + :password => password, + :password_confirmation => password, + :projects_limit => Gitlab.config.default_projects_limit ) end end |