gitolite-config with user-name in branch pattern possible? - gitolite

I want to configure something like
#developer = user1 user2
repo test
C ^dev/$user- = #developer
RW+ ^dev/$user- = #developer
So that each user in #developer has complete control over all corresponding branches under dev/ with the user-name in it.
Is there a way to make something like that happen?

Yes, this is possible:
#developer = user1 user2
repo test
RW+ dev/USER/ = #developer
(There might be some syntax errors in that snippet, I did not test it.)
See https://gitolite.com/gitolite/user.html#personal-branches for details.

Related

Get updated value from database

How do I watch for a specifc Mongodb-query? Currently I have tried with collection.watch(), but I am only getting the new value.
An example:
user1 = [user3, user4]
user2 = [user4]
If user1 follows user2, user2 should get a sign that user1 has followed. When using mongodb .watch(), I am getting [user4, user1] for user2, but I cant "detect" the new follower.
To be clear: I am searching for a solution like Instagram for instance, when someone follows you, you get a message that a user has started to follow you

Scenario hooks only valid on scenario outlines?

We're using Cucumber and Selenium with Ruby. After reading the documentation on hooks I've tried my hand at setting a few tags to set (for example) some environment variables.
Here's a contrived example that demonstrates the problem.
When I establish a Before hook like so:
Before('#tag1', '#tag2') do
puts "in the before hook!"
end
It'll take effect with a scenario defined like so:
#tag1 #tag2
Scenario Outline: This is a test scenario
Given I run my first step for "<user>"
Then I complete my test
#firstrun
Scenarios:
|user|
|fred|
#secondrun
Scenarios:
|user|
|barney|
..however if I move #tag1 and #tag2 to the individual scenarios and not the scenario outline, the hook is never called, for instance:
#secondrun #tag1 #tag2
Scenarios:
|user|
|barney|
Is it possible to 'hook in' individual scenarios, or just the outlines?
Typically with scenario outlines the table of values you're testing is tied to that, not separate scenarios.
E.g
ScenarioOutline
Given I am on gmails website
When I login as <user> with <password>
Then I am able to view my primary inbox
Example:
| user | password |
| Fred | xd13#%& |

How do I import members of one GitLab group into another

Does somebody know how I can import all members of one group into another in GitLab, rather than doing it manually one by one?
The only native feature which comes close is in lib/tasks/gitlab/bulk_add_permission.rake, which is mentioned in "User management"
# omnibus-gitlab
sudo gitlab-rake gitlab:import:all_users_to_all_groups
# installation from source
bundle exec rake gitlab:import:all_users_to_all_groups RAILS_ENV=production
You could take that as a model to develop our own task.
I am not aware of such a feature. But you can script it with the API. We use it here to add all users to one single group (all users to all groups is not feasible for our case).
Helpful documentation: http://doc.gitlab.com/ce/api/README.html, http://doc.gitlab.com/ce/api/users.html and http://doc.gitlab.com/ce/api/groups.html
There is also a respond to another question that might be helpful and lists also various modules for various programming languages: Is there a way to add users automatically into gitlab?
I was looking for a solution to Assign all Gitlab users to one particular group.
Here's the solution:
Create this file:
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/finder_import.rake
With this content:
namespace :gitlab do namespace :finder do
desc "GitLab | Add all users to group Colaboradores (admin users are added as owners)"
task importall: :environment do |t, args|
user_ids = User.where(admin: false).pluck(:id)
admin_ids = User.where(admin: true).pluck(:id)
groups = Group.where(name: "Colaboradores")
puts "Importing #{user_ids.size} users into #{groups.size} groups"
puts "Importing #{admin_ids.size} admins into #{groups.size} groups"
groups.each do |group|
puts "Importing into #{group.name}"
group.add_users(user_ids, GroupMember::DEVELOPER)
group.add_users(admin_ids, GroupMember::OWNER)
end
end
end end
Run this command:
gitlab-rake gitlab:finder:importall

Github API: How to sort public repositories by count of stars?

I am looking for api on github that could give me a count of stars for repositories
I know about /repositories which give me public repositories but I don't know how to get count of stars of repository.
Could anybody help?
From /repositories get all the public repositories. In response you would get name of the owner and also repository name, then use Get on each of those repositories. In the response of for each of those repositories, field stargazers_count will give you number of stars each repository has.
Some sample python code:
import requests
public_repos = requests.get('https://api.github.com/repositories').json()
for repo in public_repos:
repo_name = repo['name']
owner = repo['owner']['login']
repo_info = requests.get('https://api.github.com/repos/'+owner+'/'+repo_name)
stars = repo_info.json()['stargazers_count']
print(repo_name, stars)
The output is:
grit 1874
merb-core 401
rubinius 2176
god 1592
jsawesome 12
Have a look at /repositories and Get

Gitolite macro to expand to user name?

I have a config file with something like:
repo qt/[a-zA-Z0-9_\.\-]+
C = #admins
RW+ = #admins
R = #users
RW bob = bob
As you can see every user (in group #users) can read all branches
and I want bob to be able to create and push to a branch bob (and also to bob/fix and so on).
Is there a macro that would expand to the users name?
I would like to do something like:
repo qt/[a-zA-Z0-9_\.\-]+
C = #admins
RW+ = #admins
R = #users
RW USER = USER
The one Gitolite feature which would look close to what you want is "personal branch"
"Personal" branches are great for environments where developers need to share work but can't directly pull from each other (usually due to either a networking or authentication related reason, both common in corporate setups).
Personal branches exist in a namespace of their own. The syntax is
RW+ personal/USER/ = #userlist
where the "personal" can be anything you like (but cannot be empty), and the "/USER/" part is necessary (including both slashes).
A user "alice" (if she's in the userlist) can then push any branches inside personal/alice/.
Which means she can push personal/alice/foo and personal/alice/bar, but NOT personal/alice.
(Background: at runtime the "USER" component will be replaced by the name of the invoking user. Access is determined by the right hand side, as usual).
That means, when you are looking for "Is there a macro that would expand to the users name?", /USER/ would be an example of a "macro" expended to the username.

Resources