-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contribution script to generate config? #334
Comments
@aschleifer Yes, happily In the long run I am considering a Assuming there was a |
I think I think both cases are valid but not eliminating each other. On the current topic: I will make my script more generic and create a pull request. |
This seems clever. It may make sense for future command/plugin for a bitbucket/github/gitlab api wrapper to pull a list of repos.
Sounds good. If it can work with pure standard library (without requiring an additional dependency), even better. But if that makes it prohibitively difficult, feel free to use whatever packages work. |
Right now my script is a basic shell script using |
@aschleifer I think pasting it here would be a good next step, good ahead! |
#!/bin/bash
if [ -z "${GITLAB_TOKEN}" ]; then
echo 'Please provide the environment variable $GITLAB_TOKEN'
exit 1
fi
# these variables have to be set for each run
prefix="" # path to put the checkouts into (could be used as from cwd)
namespace="" # namespace/group to "scan" on gitlab instance
gitlab_host="" # gitlab hostname without protocol
current_namespace_path=""
curl --silent --show-error --header "Authorization: Bearer ${GITLAB_TOKEN}" "https://${gitlab_host}/api/v4/groups/${namespace}/projects?include_subgroups=true&per_page=100" \
| jq -r '.[]|.namespace.full_path + " " + .path' \
| LC_ALL=C sort \
| while read namespace_path reponame; do
if [ "${current_namespace_path}" != "${namespace_path}" ]; then
current_namespace_path="${namespace_path}"
echo "${prefix}/${current_namespace_path}:"
fi
# simplified config not working - https://github.com/vcs-python/vcspull/issues/332
#echo " ${reponame}: 'git+ssh://git@${gitlab_host}/${current_namespace_path}/${reponame}.git'"
echo " ${reponame}:"
echo " url: 'git+ssh://git@${gitlab_host}/${current_namespace_path}/${reponame}.git'"
echo " remotes:"
echo " origin: 'ssh://git@${gitlab_host}/${current_namespace_path}/${reponame}.git'"
done \
| tee vcspull.yaml That is the version I have right now. The first 3 variables have to be given at runtime together with the Once #332 gets resolved the 4 |
@aschleifer How about you create a PR with this script in the I was going to suggest Another possibility, if you had time, it to write the above script in vanilla python 3 w/ standard library. That would actually the best |
@tony I can easily provide this in a I haven't written python code in a while so it might take some time but could be fun to do it, but I think the first version is fine to be a shell script. |
The shell script would be fine to PR.
If you want to, optionally, you can make a second PR with python, see if you can stick to standard lib (so the user wouldn't need to install extra packages)
On 2/23/2022 10:13:22 AM, Andreas Schleifer ***@***.***> wrote:
@tony [https://github.com/tony] I can easily provide this in a scripts/ folder via PR. I will also go ahead and add make the needed variables required on execution.
I haven't written python code in a while so it might take some time but could be fun to do it, but I think the first version is fine to be a shell script.
—
Reply to this email directly, view it on GitHub [#334 (comment)], or unsubscribe [https://github.com/notifications/unsubscribe-auth/AAAGNYHAIEBKXFVO4OIHZUTU4UBSDANCNFSM5PBL3J3Q].
You are receiving this because you were mentioned.Message ID: ***@***.***>
[cbdce5b9-c7bf-4b10-84ae-949d1e211b5e]
|
Thanks for adding the scripts to the documentation ( https://vcspull.git-pull.com/config-generation.html ). If desired I can try to update the shell script to remove some of the differences between the two scripts from a usage point of view. Also, once the new command-file structure ( discussed in #333 ) is in place I might spend the time and reworking all this into a "native" vcspull command and then the two scripts get obsolete. |
Yes you are welcome to
That is coming next - i am guessing the next 2 weeks or so. The reason why I don't have a concrete date is I'm reading the codebase from scratch and would approach things differently now - some areas are so opaque it'd turn off people from contributed |
Hey @tony ,
how willing would you be to include some contribution scripts in the repository to help generate an initial config file?
I use vcspull to manage ~70 repos in my work place all under one gitlab group. I wrote a small shell script to scan this group and generate an initial config file out of it.
Initially I thought to just share this internally in my company, but if you are willing we could add this to the repository (after i made it a bit more abstract).
Please let me know your thoughts about this.
Best regards
Segaja
The text was updated successfully, but these errors were encountered: