Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Transferring ownership of a project and repository
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Allan Caffee  
View profile  
 More options Oct 4 2012, 8:14 pm
From: Allan Caffee <allan.caf...@gmail.com>
Date: Thu, 4 Oct 2012 17:14:40 -0700 (PDT)
Local: Thurs, Oct 4 2012 8:14 pm
Subject: Transferring ownership of a project and repository

I'm trying to transfer the ownership of a project and repository belonging
to someone whose account has been disabled. Since the account is disabled
I'm trying to use the ruby console to transfer ownership, but I'm getting a
NoMethodError using the methods defined on these models. I'm new to
ruby/rails so it's possible I'm overlooking something fairly obvious, but
here's what I'm doing:

% env RAILS_ENV=production ruby script/console

>> user = User.find_by_login('username')

=> #<User id: 23, ...>
>> proj = Project.find_by_slug('foo-project)

=> #<Project id: 121, ...>
>> proj.change_owner_to user

NoMethodError: undefined method `change_owner_to' for
#<Project:0x7f8ad0202da0>
    from
/var/www/gitorious/vendor/rails/activerecord/lib/active_record/attribute_me thods.rb:260:in
`method_missing'
    from (irb):32

What am I missing here? Is there a better way to do this? I'm using
gitorious v2.1.1.

Thanks,
Allan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Kjellerstedt  
View profile  
 More options Oct 5 2012, 6:17 am
From: Peter Kjellerstedt <peter.kjellerst...@axis.com>
Date: Fri, 5 Oct 2012 12:17:06 +0200
Local: Fri, Oct 5 2012 6:17 am
Subject: RE: [gitorious] Transferring ownership of a project and repository

I use the following function to change the ownership of a project to another user:

def change_project_owner(project, owner, keep_old = true)
  p = Project.find_by_title(project)
  u = User.find_by_login(owner)
  old_owner = p.owner

  return if u == old_owner

  p.repositories.mainlines.each do |r|
    cs = r.committerships.find_by_committer_id_and_committer_type(u.id, "User")
    if cs
      cs.destroy
    end
  end
  p.change_owner_to(u).each do |r|
    r.change_owner_to!(u)
    r.user_id = u.id
    r.save!
    r.committerships.find_all_by_committer_type("User").each do |cs|
      if cs.committer_id == u.id
        cs.creator_id = nil
        cs.save!
      elsif cs.creator_id == old_owner.id
        cs.creator_id = u.id
        cs.save!
      end
    end
    if keep_old
      cs = r.committerships.create!(:committer => old_owner, :creator_id => u.id)
      cs.build_permissions(:review, :commit, :admin)
      cs.save!
    end
  end
  p.save!
end

Note that I use Project.find_by_title() which you can easily change to Project.find_by_slug(). I also do not know what will happen if there are group committerships involved (we do not use groups). Set keep_old to true if you want the old owner to retain his/her committerships after the owner change.

//Peter

From: gitorious@googlegroups.com [mailto:gitorious@googlegroups.com] On Behalf Of Allan Caffee
Sent: den 5 oktober 2012 02:15
To: gitorious@googlegroups.com
Subject: [gitorious] Transferring ownership of a project and repository

I'm trying to transfer the ownership of a project and repository belonging to someone whose account has been disabled. Since the account is disabled I'm trying to use the ruby console to transfer ownership, but I'm getting a NoMethodError using the methods defined on these models. I'm new to ruby/rails so it's possible I'm overlooking something fairly obvious, but here's what I'm doing:

% env RAILS_ENV=production ruby script/console

>> user = User.find_by_login('username')

=> #<User id: 23, ...>
>> proj = Project.find_by_slug('foo-project)

=> #<Project id: 121, ...>
>> proj.change_owner_to user

NoMethodError: undefined method `change_owner_to' for #<Project:0x7f8ad0202da0>
    from /var/www/gitorious/vendor/rails/activerecord/lib/active_record/attribute_me thods.rb:260:in `method_missing'
    from (irb):32

What am I missing here? Is there a better way to do this? I'm using gitorious v2.1.1.

Thanks,
Allan
--
To post to this group, send email to gitorious@googlegroups.com<mailto:gitorious@googlegroups.com>
To unsubscribe from this group, send email to
gitorious+unsubscribe@googlegroups.com<mailto:gitorious+unsubscribe@googleg roups.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Allan Caffee  
View profile  
 More options Oct 5 2012, 3:59 pm
From: Allan Caffee <allan.caf...@gmail.com>
Date: Fri, 5 Oct 2012 12:59:26 -0700 (PDT)
Local: Fri, Oct 5 2012 3:59 pm
Subject: Re: [gitorious] Transferring ownership of a project and repository

I tried your function with the tweaks you suggested, but I'm still getting
an error:

>>  change_project_owner('foo-project', 'username')

TypeError: wrong argument type nil (expected Module)
    from /var/www/gitorious/lib/gitorious/search.rb:41:in `extend'
    from /var/www/gitorious/lib/gitorious/search.rb:41:in `included'
    from /var/www/gitorious/app/models/repository.rb:32:in `include'
    from /var/www/gitorious/app/models/repository.rb:32
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:158:in
`require'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:158:in
`require'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:265:in
`require_or_load'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:425:in
`load_missing_constant'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:80:in
`const_missing'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:92:in
`const_missing'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:437:in
`load_missing_constant'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:96:in
`const_missing'
    from /var/www/gitorious/app/models/user.rb:33
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:158:in
`require'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:158:in
`require'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:265:in
`require_or_load'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:425:in
`load_missing_constant'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:80:in
`const_missing'
    from
/var/www/gitorious/vendor/rails/activesupport/lib/active_support/dependenci es.rb:92:in
`const_missing'
    from (irb):39:in `change_project_owner'
    from (irb):72>>

I'm wondering if there is something wrong with my environment which causes
my console not to properly load up all of the functionality of the models.
I'm not very familiar with how ruby works.

--
Allan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »