Prefix Support

1 view
Skip to first unread message

Jeff Anderson

unread,
Jun 12, 2009, 9:07:09 PM6/12/09
to smug...@googlegroups.com
This patch has a cool new feature. You can specify a prefix to the path
loaded from the git repository. For example, I might have a repository
for a class that looks like this:

ecen224/
+notes/
+homework/
+research papers/
+projects/

Previously, with smug, I'd have to share the entire repo. The root
directory of the repo is basically grafted onto a location on my
website with a urlconf that might look like this:

(r'^school/ecen224/', include('smug.urls'), {'repo': 'ecen224',})

If I want to share my notes only, but not my homework or anything else,
I can now do the following:

(r'^school/ecen224/', include('smug.urls'), {'repo': 'ecen224',
'prefix': 'notes/'}),

This is effectively grafting a single subdirectory to my web page. I can
even define multiple url patterns with different prefixes on the same
repository.

So, anyway here's the patch. I'm planning on adding all the info in this
message to the documentation, but the documentation is a bit behind at
the moment.


Thanks!

Jeff Anderson

prefix.diff

Andrew McNabb

unread,
Jun 13, 2009, 12:20:51 AM6/13/09
to smug...@googlegroups.com
On Fri, Jun 12, 2009 at 07:07:09PM -0600, Jeff Anderson wrote:
> This patch has a cool new feature. You can specify a prefix to the path
> loaded from the git repository.

I think it's a great feature to have. I took some liberties with the
patch because I was uncomfortable with having load.py have to worry
about the prefix. I just created a branch called "prefix" where I
commited your changes with my modifications. Do you see any drawbacks
to the changed version? I wouldn't be surprised if you had a reason
that I didn't see.

Thanks for sending in your improvements.


--
Andrew McNabb
http://www.mcnabbs.org/andrew/
PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868

Jeff Anderson

unread,
Jun 13, 2009, 1:10:32 AM6/13/09
to smug...@googlegroups.com
On Fri, Jun 12, 2009 at 10:20:51PM -0600, Andrew McNabb wrote:
> On Fri, Jun 12, 2009 at 07:07:09PM -0600, Jeff Anderson wrote:
> > This patch has a cool new feature. You can specify a prefix to the path
> > loaded from the git repository.
>
> I think it's a great feature to have. I took some liberties with the
> patch because I was uncomfortable with having load.py have to worry
> about the prefix. I just created a branch called "prefix" where I
> commited your changes with my modifications. Do you see any drawbacks
> to the changed version? I wouldn't be surprised if you had a reason
> that I didn't see.

Your version of the patch looks wonderful.

The only reason I passed around the prefix everywhere instead of
calculating it at the first chance was in case it caused an unforeseen
interaction with the lower level code later on. Being able to tell if a
path is prefixed or not would make debugging similar *if* it ever causes
a problem, but not impossible.

With that said, your version is cleaner, and I like it better.


Thanks!

Jeff Anderson

Andrew McNabb

unread,
Jun 13, 2009, 1:56:43 AM6/13/09
to smug...@googlegroups.com
On Fri, Jun 12, 2009 at 11:10:32PM -0600, Jeff Anderson wrote:
>
> Your version of the patch looks wonderful.

Why, thank you. :)

Would you mind giving it a test? If all goes well, I'll go ahead and
merge it into the master branch.

Jeff Anderson

unread,
Jun 13, 2009, 2:25:59 AM6/13/09
to smug...@googlegroups.com
On Fri, Jun 12, 2009 at 11:56:43PM -0600, Andrew McNabb wrote:
>
> On Fri, Jun 12, 2009 at 11:10:32PM -0600, Jeff Anderson wrote:
> >
> > Your version of the patch looks wonderful.
>
> Why, thank you. :)
>
> Would you mind giving it a test? If all goes well, I'll go ahead and
> merge it into the master branch.

It seems to work just as well. I just checked yours out, and nothing
broke. I did all the same tests that I did when I wrote the first patch,
so any bugs that are in yours are in mine too.


Jeff Anderson

Andrew McNabb

unread,
Jun 13, 2009, 11:33:08 AM6/13/09
to smug...@googlegroups.com
On Sat, Jun 13, 2009 at 12:25:59AM -0600, Jeff Anderson wrote:
>
> It seems to work just as well. I just checked yours out, and nothing
> broke. I did all the same tests that I did when I wrote the first patch,
> so any bugs that are in yours are in mine too.

I'll merge this in later today, then. Thanks.

Jonathan Wilson

unread,
Jun 15, 2009, 9:16:58 PM6/15/09
to smug...@googlegroups.com
On Sat, Jun 13, 2009 at 09:33:08AM -0600, Andrew McNabb wrote:
> >
> > It seems to work just as well. I just checked yours out, and nothing
> > broke. I did all the same tests that I did when I wrote the first patch,
> > so any bugs that are in yours are in mine too.
>
> I'll merge this in later today, then. Thanks.
>

This brings up a good question - should we start looking at adding a
unit/doc test suite to smug?

--
Jonathan Wilson

Andrew McNabb

unread,
Jun 16, 2009, 12:36:35 PM6/16/09
to smug...@googlegroups.com
On Mon, Jun 15, 2009 at 07:16:58PM -0600, Jonathan Wilson wrote:
>
> This brings up a good question - should we start looking at adding a
> unit/doc test suite to smug?

I think that's a great idea. We already have some doctests in gitlib,
but we don't have any on the Django side. The main reason that this
hasn't happened yet is that I don't have much experience writing unit
tests for web apps. It's definitely a good idea.

Reply all
Reply to author
Forward
0 new messages