aboutsummaryrefslogtreecommitdiff
path: root/git-arr
Commit message (Collapse)AuthorAgeFilesLines
* Cache some (possibly) expensive function callsAlberto Bertogli2022-09-011-1/+1
| | | | | | This patch memoizes some of the functions to help speed up execution. The speedup is quite variable, but ~30% is normal when generating a medium size repository, and the output is byte-for-byte identical.
* Introduce type annotationsAlberto Bertogli2020-05-241-6/+7
| | | | | | | This patch introduces type annotations, which can be checked with mypy. The coverage is not very comprehensive for now, but it is a starting point and will be expanded in later patches.
* Auto-format the code with blackAlberto Bertogli2020-05-241-168/+236
| | | | | | | | | | | | | This patch applies auto-formatting of the source code using black (https://github.com/psf/black). This makes the code style more uniform and simplifies editing. Note I also tried yapf, and IMO produced nicer output and handled some corner cases much better, but unfortunately it doesn't yet support type annotations, which will be introduced in later commits. So in the future we might switch to yapf instead.
* Move to Python 3Alberto Bertogli2020-05-241-13/+11
| | | | | | | | | | | Python 3 was released more than 10 years ago, and support for Python 2 is going away, with many Linux distributions starting to phase it out. This patch migrates git-arr to Python 3. The generated output is almost exactly the same, there are some minor differences such as HTML characters being quoted more aggresively, and handling of paths with non-utf8 values.
* Implement a "patch" view0.15Alberto Bertogli2018-10-011-0/+17
| | | | | This commit implements a "patch" view, with a simple plain-text representation of a commit, that can be used as a patch file.
* Add a "prefix" configuration optionAlberto Bertogli2017-07-301-7/+12
| | | | | | | | This patch adds a "prefix" configuration option, so repositories created with recursion are named with a prefix. This can be useful to disambiguate between repositories that are named the same but live in different directories.
* git-arr: Implement an "ignore" optionAlberto Bertogli2015-11-071-2/+7
| | | | | | | | When having symbolic links to the same repositories (e.g. if you have "repo" and a "repo.git" linking to it), it can be useful to ignore based on regular expressions to avoid having duplicates in the output. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* git-arr: Always generate the top level indexAlberto Bertogli2015-11-071-11/+9
| | | | | | | | | | | The top level index contains a "last updated" field, but it doesn't get updated if using the --only option, which is very common in post-update hooks, and causes the date to be stale. This patch fixes that by always generating the top level index, even if --only was given. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* branch: pass branch name view explicitlyEric Sunshine2015-01-171-1/+1
| | | | | | | | | | | Passing the branch name into the view indirectly via Repo.new_in_branch() increases cognitive burden, thus outweighing whatever minor convenience (if any) is gained by doing so. The code is easier to reason about when the branch name is passed to the view directly. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* blob: pass branch name to view explicitlyEric Sunshine2015-01-171-4/+3
| | | | | | | | | | | Passing the branch name into the view indirectly via Repo.new_in_branch() increases cognitive burden, thus outweighing whatever minor convenience (if any) is gained by doing so. The code is easier to reason about when the branch name is passed to the view directly. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* tree: pass branch name to view explicitlyEric Sunshine2015-01-171-2/+2
| | | | | | | | | | | Passing the branch name into the view indirectly via Repo.new_in_branch() increases cognitive burden, thus outweighing whatever minor convenience (if any) is gained by doing so. The code is easier to reason about when the branch name is passed to the view directly. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* blob: render hexdump(1)-style binary blob contentEric Sunshine2015-01-131-0/+1
| | | | | | | | | | | | | | Raw binary blob content tends to look like "line noise" and is rarely, if ever, meaningful. A hexdump(1)-style rendering (specifically, "hexdump -C"), on the other hand, showing runs of hexadecimal byte values along with an ASCII representation of those bytes can sometimes reveal useful information about the data. (A subsequent patch will add the ability to cap the amount of data rendered in order to reduce storage space requirements.) Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* blob: render binary blob summary information rather than raw contentEric Sunshine2015-01-131-0/+1
| | | | | | | | | | | | | | | | | Binary blobs are currently rendered as raw data directly into the HTML output, looking much like "line noise". This is rarely, if ever, meaningful, and consumes considerable storage space since the entire raw blob content is embedded in the generated HTML file. Address this issue by instead emitting summary information about the blob, such as its classification ("binary") and its size. Other information can be added as needed. As in Git itself, a blob is considered binary if a NUL is present in the first ~8KB. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* git-arr: increase default 'max_pages' valueEric Sunshine2015-01-121-1/+1
| | | | | | | | | | | | | The 'max_pages' default value of 5 is quite low. Coupled with 'commits_per_page' default 50, this allows for only 250 commits, which is likely unsuitable for even relatively small projects. Options are to remove the cap altogether or to raise the default limit. At this time, choose the latter, which should be friendlier to larger projects, in general, while still guarding against run-away storage space consumption. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* route: recognize hierarchical branch namesEric Sunshine2015-01-111-6/+6
| | | | | | | | | Branch names in Git may be hierarchical (for example, "wip/parser/fix"), however, git-arr's Bottle routing rules do not take this into account. Fix this shortcoming. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* route: prepare to fix routing of hierarchical branch namesEric Sunshine2015-01-111-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | Branch names in Git may be hierarchical (for example, "wip/parser/fix"), however, git-arr does not take this into account in its Bottle routing rules. Unfortunately, when updated to recognize hierarchical branch names, the rules become ambiguous in their present order since Bottle matches them in the order registered. The ambiguity results in incorrect matches. For instance, branch pages (/r/<repo>/b/<bname>/) are matched before tree pages (/r/<repo>/b/<bname>/t/), however, when branch names can be hierarchical, a tree path such as "/r/proj/b/branch/t/" also looks like a branch named "branch/t", and thus undesirably matches the branch rule rather than the tree rule. This problem can be resolved by adjusting the order of rules. Therefore, re-order the rules from most to least specific as a preparatory step prior to actually fixing them to accept hierarchical branch names. This is a purely textual relocation. No functional changes intended. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* repo: diff: add option to show "creation event" diff for root commitEric Sunshine2015-01-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | At its inception, Git did not show a "creation event" diff for a project's root commit since early projects, such as the Linux kernel, were already well established, and a large root diff was considered uninteresting noise. On the other hand, new projects adopting Git typically have small root commits, and such a "creation event" is likely to have meaning, rather than being pure noise. Consequently, git-diff-tree gained a --root flag in dc26bd89 (diff-tree: add "--root" flag to show a root commit as a big creation event, 2005-05-19), though it was disabled by default. Displaying the root "creation event" diff, however, became the default behavior when configuration option 'log.showroot' was added to git-log in 0f03ca94 (config option log.showroot to show the diff of root commits; 2006-11-23). And, gitk (belatedly) followed suit when it learned to respect 'log.showroot' in b2b76d10 (gitk: Teach gitk to respect log.showroot; 2011-10-04). By default, these tools now all show the root diff as a "creation event", however, git-arr suppresses it unconditionally. Resolve this shortcoming by adding a new git-arr configuration option "rootdiff" to control the behavior (enabled by default). Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* git-arr: interpret 'max_pages = 0' as unlimitedEric Sunshine2015-01-111-0/+2
| | | | | | | | | | | By default, git-arr limits the number of pages of commits to 5, however, it is reasonable to expect that some projects will want all commits to be shown. Rather than forcing such projects to choose an arbitrarily large number as the value of 'max_pages', provide a formal mechanism to specify unlimited commit pages. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* write_tree: suppress double-slash in blob HTML filenameEric Sunshine2015-01-111-2/+3
| | | | | | | | | | | | | | | When emitting a blob in the root tree of a commit, write_tree() composes the blob's HTML filename with an extra slash before the "f=", like this: output/r/repo/b/master/t//f=README.txt.html Although the double-slash is not harmful on Unix, it is unsightly, and may be problematic for other platforms or filesystems which interpret double-slash specially or disallow it. Therefore, suppress the extra slash for blobs in the root tree. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* route: commit: match only hexadecimal rather than digits + full alphabetEric Sunshine2015-01-111-1/+1
| | | | | | | | | A human-readable representation of a Git SHA1 commit ID is composed only of hexadecimal digits, thus there is no need to match against the full alphabet. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* git: Add '--' to "git rev-list" runs to avoid ambiguous argumentsAlberto Bertogli2014-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there is a branch and a file with the same name, git-arr will fail to generate, as git will complain when running git rev-list. For example, if there is both a file and a branch called "hooks" in the repository, git-arr would fail as follows: === git-arr running: ['git', '--git-dir=/some/repo', 'rev-list', '--max-count=1', '--header', u'hooks']) fatal: ambiguous argument 'hooks': both revision and filename Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' Traceback (most recent call last): File "./git-arr", line 457, in <module> main() File "./git-arr", line 452, in main skip_index = len(opts.only) > 0) File "./git-arr", line 388, in generate branch_mtime = r.commit(bn).committer_date.epoch AttributeError: 'NoneType' object has no attribute 'committer_date' To fix that, this patch appends a "--" as the last argument to rev-list, which indicates that it has completed the revision list, which disambiguates the argument. While at it, a minor typo in a comment is also fixed. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Work around HTTPError status code issuesAlberto Bertogli2013-11-031-1/+11
| | | | | | | | | | | It turned out that bottle.py is not backwards-compatible with the status code change: older versions encode the status in e.status; newer ones use e.status_code (and e.status became a string). This patch works around that by trying to pick up which of the two variants we have, and deciding accordingly. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Show the age of a repository in the index, via javascriptAlberto Bertogli2013-11-021-0/+2
| | | | | | | | | This patch adds the age of the repository to the index view, using javascript to give a nice human string for the age. When javascript is not available, the element remains hidden. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Use the status_code attribute to tell 404s appartAlberto Bertogli2013-11-021-1/+1
| | | | | | | | Newer versions of bottle have a string in the e.status attribute, and the status code can be found in e.status_code, which should be backwards compatible. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Make embedding markdown and images configurable per-repoAlberto Bertogli2013-11-021-0/+5
| | | | | | | | This patch introduces the embed_markdown and embed_images configuration options, so users can enable and disable those features on a per-repository basis. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Add embed data URI image blob supportVanya Sergeev2013-11-021-0/+2
|
* Add markdown blob supportVanya Sergeev2013-11-021-0/+2
|
* Allow calling the executable from any directoryAlberto Bertogli2013-03-101-5/+18
| | | | | | | | | | | | | | | When the tool is invoked like /path/to/git-arr, it currently fails because both the serving of static files and bottle templates assume they're on the current working directory. This patch fixes that by computing the directories based on the executable location. Note this is assuming the static directory and the templates live next to the executable, which will not always be the case, and eventually it should be configurable; but it's ok for the time being. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Use "cloneurl" as a default for git_urlAlberto Bertogli2013-03-101-1/+1
| | | | | | This patch makes git_url have the same default as gitweb. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Fix the "--only" optionAlberto Bertogli2013-03-101-5/+9
| | | | | | | | | | | This patch fixes the --only option, and makes it avoid generating the top-level index so we don't get a broken one with only the specified repositories. The intention is that this option is used in hooks to update the views after a commit or push. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Use heuristics to decide what to colorizeAlberto Bertogli2012-11-181-1/+1
| | | | | | | In practise pygments seems to have a very hard time processing large files and files with long lines, so try to avoid using it in those cases. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Improve the way we find repo pathsAlberto Bertogli2012-11-111-8/+34
| | | | | | | | | | This patch improves the way we find the path to the repositories, both in the recursive and in the non-recursive cases. We now support specifying non-bare repositories directly, and also recursing on them. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
* Initial commit0.01Alberto Bertogli2012-11-101-0/+390
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>