Skip to content
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

Add post-checkout/clone entry point for custom code #2

Open
reinout opened this issue Aug 21, 2015 · 2 comments
Open

Add post-checkout/clone entry point for custom code #2

reinout opened this issue Aug 21, 2015 · 2 comments

Comments

@reinout
Copy link
Owner

reinout commented Aug 21, 2015

See https://bitbucket.org/reinout/checkoutmanager/issues/23/allow-an-user-defined-init-command-to-run

@reinout
Copy link
Owner Author

reinout commented Aug 21, 2015

Original question by @do3cc:

I'd love to have the option to define a script that shall be called after a fresh checkout. I use virtualenvwrapper, and when checkoutmanager checks out a new repo, my first action always is to rename the dir, create a project with the same name and copy the renamed contents into the new project dir.

I've now created a script for myself and it contains a lot of special logic already that is not virtualenvwrapper specific: https://gist.github.com/do3cc/520c9b0b03466f2bf469

So I think the option is the best way forward, but maybe you have an even better idea. Else I create a PR

@reinout
Copy link
Owner Author

reinout commented Aug 21, 2015

(Copy of my original answer from the bitbucket issue:)

Having checkoutmanager call something after a checkout? Nice idea, sounds useful. It also sounds like a "post-checkout" command, which suggests that someone might like a "post-update" command

What do you mean by "option"? Something like "checkoutmanager co --co-script=/usr/local/bin/something.sh"? Or do you want a special "[checkoutmanager]" entry in the config file with one or more options?

Taking the last idea (I'm brainstorming...), checkoutmanager could look for a "post-checkout/post-update" entry in every section, which means you could swich on something like this just for specific kinds of checkouts. With a fallback to a default in "[checkoutmanager]".

Alternatively, we could use setuptools' entry points. I have that in zest.releaser (http://zestreleaser.readthedocs.org/en/latest/entrypoints.html) and it works like a charm. People use that to customize zest.releaser's behaviour. It is a great way to get rid of the more outrageous pull request: "just write it as a custom entry point". :-)

The advantage: you don't need to pass any option. If you want something custom, just install some package and checkoutmanager will automatically pick it up.

Also an advantage: because you're calling a python function, you can easily pass a bunch of arguments. Directory name, checkout url, options in the section (possibly useful to configure the entry point...).

This brings me to another point: do we want to call a script (python/shell/binary/whatever) or do we want to call a python function? Personally I'd now go for the python function in combination with an entry point. Nothing stops you from just calling a shell script in the python function, of course.

What are your thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant