Note that there are some explanatory texts on larger screens.

plurals
  1. POIn a git-based CMS, how to uniquely identify files in git repository?
    primarykey
    data
    text
    <p>I'm working on a simple CMS (based on Django, not that it matters) similar to <a href="http://github.com/mojombo/jekyll" rel="nofollow noreferrer">Jekyll</a> and <a href="http://ringce.com/hyde" rel="nofollow noreferrer">Hyde</a>, but dynamic instead of static. The idea is that the server has a copy of the repository, I can push stuff into that, and the CMS will automatically pick up the new content.</p> <p>Let's say that Markdown-formatted blog posts in my repository follow this file naming scheme:</p> <pre><code>/blog/2010/08/14/my-blog-post.md </code></pre> <p>Internally, the processed files will be cached in a SQLite database under a unique ID, for easy searching and fast serving.</p> <p>The problem is in constructing the URLs in such a way that they can be mapped to files in the repository. I see several options:</p> <ol> <li><p><code>/blog/2010/08/14/my-blog-post</code><br> If I simply map (part of) the URL to a filename, renaming a file will break all links pointing to that file. The content admin can leave a symlink in place of the old file, which the CMS can map into a HTTP redirect, but this requires work that is easy to forget.</p></li> <li><p><code>/blog/2010/08/14/271-my-blog-post</code><br> If I include a database ID in every URL, clearing or rebuilding the cache will invalidate all IDs, which is even worse. I would like the git repository to be the only thing representing the site's contents; everything else should be reconstructible from that.</p></li> <li><p><code>/blog/2010/08/14/528dc05-my-blog-post</code><br> The only thing uniquely identifying a file in the repo over time, as far as I can tell, is a pair (filename, SHA1). That file is guaranteed to exist in that commit, and we can trace it to the current HEAD through the git log.<br> (I won't include the full SHA1, but just enough to make collisions sufficiently unlikely. Will do the math later.)</p></li> </ol> <p>My question is twofold:</p> <ul> <li><p>Is there an easy and fast way in git to track a (filename, SHA1) pair through renames to the corresponding filename in the current HEAD?</p></li> <li><p>Is there a better way to accomplish my goals: not breaking existing URLs, but still allowing for renames and cache rebuilds?</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload