Commit graph

72 commits

Author SHA1 Message Date
David Bremner
803ac83c46 nmbug: promote to user tool "notmuch-git"
Initially just a rename, and drop the --version argument that clashes
with the global notmuch --version argument.
2022-06-17 08:40:19 -03:00
Tomi Ollila
a12bf2a52a nmbug: notmuch-report: set both background and foreground colors
Whenever setting background color, set also corresponding
foreground color. Don't expect default foreground color to
be #000 (or something close); user may have changed it.
2021-01-09 11:29:07 -04:00
Daniel Kahn Gillmor
144cf30e2c nmbug: explicitly prefer python3
nmbug and notmuch-report are developer tools.  It's 2018, and all
developers should have python3 available.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2020-04-03 09:33:44 -03:00
Daniel Kahn Gillmor
0741e48c3d use #!/usr/bin/env python consistently 2018-06-14 20:38:20 -03:00
Daniel Kahn Gillmor
c20a5eb805 move more http -> https
Correct URLs that have crept into the notmuch codebase with http://
when https:// is possible.

As part of this conversion, this changeset also indicates the current
preferred upstream URLs for both gmime and sup.  the new URLs are
https-enabled, the old ones are not.

This also fixes T310-emacs.sh, thanks to Bremner for catching it.
2018-05-03 20:59:20 -03:00
W. Trevor King
75477003e9 nmbug: Bump to version 0.3
Changes since 0.2:

* Accept failures to unset core.worktree in clone (0a155847,
  2017-10-10, unreleased).
* Use --no-renames in log (f9189a06, 2016-09-26, v0.24).
* Auto-checkout in clone if it wouldn't clobber (7ef3b653, 2017-10-10,
  unreleased).
* Add a 'help' command for folks who don't like --help
  (9d25c97d, 2014-10-03, v0.20).
* Setup a 'config' branch on clone to track origin/config (244f8739,
  2015-03-22, v0.20).  This branch may be consumed by
  notmuch-report(1).
* Only error for invalid diff lines in tags/ (57225988, 2017-10-16,
  unreleased).
* Ignore # comments in 'notmuch dump ...' output (9bbc54bd,
  2016-03-27, v0.22).
* Respect 'expect' in _spawn(..., wait=True) (e263c5b1, 2017-10-10,
  unreleased).
* Update URLs in documentation (554b90b5 and 6a833a6e8, 2016-06-02,
  v0.23).
2017-12-29 16:44:20 -04:00
W. Trevor King
572259885a nmbug: Only error for invalid diff lines in tags/
Avoid:

  Traceback (most recent call last):
    File "/home/nmbug/bin/nmbug", line 834, in <module>
      args.func(**kwargs)
    File "/home/nmbug/bin/nmbug", line 385, in checkout
      status = get_status()
    File "/home/nmbug/bin/nmbug", line 580, in get_status
      maybe_deleted = _diff_index(index=index, filter='D')
    File "/home/nmbug/bin/nmbug", line 658, in _diff_index
      for id, tag in _unpack_diff_lines(stream=p.stdout):
    File "/home/nmbug/bin/nmbug", line 678, in _unpack_diff_lines
      'Invalid line in diff: {!r}'.format(line.strip()))
  ValueError: Invalid line in diff: u'.mailmap'

With this commit, folks can commit READMEs, .mailmap, etc. to their
nmbug repositories, and 'nmbug diff' and 'status' won't choke on them.
If you want to check for this sort of thing, you can set --log-level
to info or greater.  nmbug will still error if the unrecognized path
is under tags/, since that's more likely to be a user error.
2017-12-16 08:20:13 -04:00
W. Trevor King
7ef3b65376 nmbug: Auto-checkout in clone if it wouldn't clobber
We currently auto-checkout after pull and merge to make those more
convenient.  They're guarded against data-loss with a leading
_insist_committed().  This commit adds the same convenience to clone,
since in most cases users will have no NMBPREFIX-prefixed tags in
their database when they clone.  Users that *do* have
NMBPREFIX-prefixed tags will get a warning (and I've bumped the
default log level to warning so folks who don't set --log-level will
see it) like:

  $ nmbug clone http://nmbug.notmuchmail.org/git/nmbug-tags.git
  Cloning into '/tmp/nmbug-clone.g9dvd0tv'...
  Checking connectivity: 16674, done.
  Branch config set up to track remote branch config from origin.
  Not checking out to avoid clobbering existing tags: notmuch::0.25, ...
2017-12-11 09:07:09 -04:00
W. Trevor King
0a1558471f nmbug: Accept failures to unset core.worktree in clone
Since 6311cfaf (init: do not set unnecessary core.worktree,
2016-09-25, 2.11.0 [1]), Git has no longer set core.worktree when
--separate-git-dir is used.  This broke clone with:

  $ nmbug clone http://nmbug.notmuchmail.org/git/nmbug-tags.git
  Cloning into '/tmp/nmbug-clone.33gg442e'...
  Checking connectivity: 16674, done.
  ['git', '--git-dir', '/home/wking/.nmbug', 'config', '--unset', 'core.worktree'] exited with 5
  $ echo $?
  1

The initial discussion that lead to the Git change is in [2], and
there is some more discussion around this specific change in [3].
There is some useful background on working trees in this 2009 message
[4].  There is also a git-worktree(1) since df0b6cfb (worktree: new
place for "git prune --worktrees", 2015-06-29, 2.5.0 [5]) which grew
the ability to add new worktrees in 799767cc (Merge branch
'es/worktree-add', 2015-07-13, 2.5.0 [6]).  Folks relying on
core.worktree in the --separate-git-dir case fall into the "former
case" in [4], and as Junio pointed out in that message, Git
operations like 'add' don't really work there.

In nmbug we don't want core.worktree, because our effective working
tree is the notmuch database.  By accepting failed core.worktree
unsets, clone will work with Gits older and younger than 2.11.0.

[1]: 6311cfaf93
[2]: https://public-inbox.org/git/CALqjkKZO_y0DNcRJjooyZ7Eso7yBMGhvZ6fE92oO4Su7JeCeng@mail.gmail.com/
[3]: https://public-inbox.org/git/87h94d8cwi.fsf@kyleam.com/
[4]: https://public-inbox.org/git/7viqbsw2vn.fsf@alter.siamese.dyndns.org/
[5]: df0b6cfbda
[6]: 799767cc98

Reported-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2017-12-11 09:06:47 -04:00
W. Trevor King
e263c5b1f9 nmbug: Respect 'expect' in _spawn(..., wait=True)
Fixing a bug from 7f2cb3be (nmbug: Translate to Python, 2014-10-03).
The bug had no direct impact though, because none of the wait=True
callers were setting expect.

Also add expected codes to the debug messages, to help log readers
understand why nonzero exits are occasionally accepted.
2017-12-11 09:06:30 -04:00
Vladimir Panteleev
ca4688e103 Use rooted paths in .gitignore files
A leading / in paths in a .gitignore file matches the beginning of the
path, meaning that for patterns without slashes, git will match files
only in the current directory as opposed to in any subdirectory.

Prefix relevant paths with / in .gitignore files, to prevent
accidentally ignoring files in subdirectories and possibly slightly
improve the performance of "git status".
2017-08-18 19:42:35 -03:00
W. Trevor King
f9189a062b nmbug: Add --no-renames to default log options
Git has supported this since b68ea12e (diff.c: respect diff.renames
config option, 2006-07-07, v1.4.2).  All of our information is in the
paths (the files are empty), so we don't want rename detection.  By
using --no-renames, we get entries like:

  $ nmbug log -- e473b453a2
  commit e473b453a25c072b5df67d834d822121373321f5
  Author: David Bremner <david@tethera.net>
  Date:   Sun Sep 25 07:54:11 2016 -0300

  D       tags/1474196252-31700-1-git-send-email-markwalters1009@gmail.com/0.23
  A       tags/1474196252-31700-1-git-send-email-markwalters1009@gmail.com/pushed

  ...

Instead of the old:

  $ nmbug log -- e473b453a2
  commit e473b453a25c072b5df67d834d822121373321f5
  Author: David Bremner <david@tethera.net>
  Date:   Sun Sep 25 07:54:11 2016 -0300

  R100    tags/1474196252-31700-1-git-send-email-markwalters1009@gmail.com/0.23   tags/1474196252-31700-1-git-send-email-markwalters1009@gmail.com/pushed
2016-10-04 07:51:22 -03:00
Daniel Kahn Gillmor
6a833a6e83 Use https instead of http where possible
Many of the external links found in the notmuch source can be resolved
using https instead of http.  This changeset addresses as many as i
could find, without touching the e-mail corpus or expected outputs
found in tests.
2016-06-05 08:32:17 -03:00
Daniel Kahn Gillmor
554b90b58e nmbug: updated to modern URL for PEP 343 2016-06-05 08:27:13 -03:00
David Bremner
9bbc54bd40 nmbug: ignore # comments
Lines starting with # have always (for a long time, anyway) been ignored
by notmuch-restore, but have not been generated by notmuch-dump
previously.  In order to make nmbug robust against such output, ignore
comment lines.
2016-03-28 09:29:42 -03:00
W. Trevor King
d6cbb24fcf notmuch-report: Add notmuch-report(1) and notmuch-report.json(5) man pages
To describe the script and config file format, so folks don't have to
dig through NEWS or the script's source to get that information.

The Makefile and conf.py are excerpted from the main doc/ directory
with minor simplifications and adjustments.  The devel/nmbug/ scripts
are largely independent of notmuch, and separating the docs here
allows packagers to easily build the docs and install the scripts in a
separate package, without complicating notmuch's core build/install
process.
2016-03-24 07:41:24 -03:00
W. Trevor King
399c857eba notmuch-report.json: Rename from status-config.json
status-config.json wasn't obviously associated with the old
nmubg-status, now notmuch-report.  The new name is
${CONFIGURED_SCRIPT}.json, so the association should be clear.
2016-03-24 07:41:06 -03:00
W. Trevor King
074f45e305 notmuch-report: Rename from nmbug-status
This script generates reports based on notmuch queries, and doesn't
really have anything to do with nmbug, except for sharing the NMBGIT
environment variable.
2016-03-24 07:40:39 -03:00
W. Trevor King
88171f34ed status-config.json: Remove parens from query entry
These are now added by nmbug-status.
2016-03-24 07:39:57 -03:00
W. Trevor King
6c0b6c8e1c nmbug-status: Wrap query phrases in parentheses when and-ing together
For example:

  "query": ["tag:a", "tag:b or tag:c"]

is now converted to:

  ( tag:a ) and ( tag:b or tag:c )

instead of the old:

  tag:a and tag:b or tag:c

This helps us avoid confusion due to Xapian's higher-precedence AND
[1], where the old query would be interpreted as:

  ( tag:a and tag:b ) or tag:c

[1]: http://xapian.org/docs/queryparser.html
2016-03-24 07:39:42 -03:00
W. Trevor King
031ca3f1bd nmbug-status: Add meta.message-url config setting
So you can link to archives other than Gmane.  For example, I'm doing
this in [1].

[1]: https://github.com/wking/nmbug-oci
2016-03-24 07:39:25 -03:00
W. Trevor King
d6204e8362 nmbug-status: Fix unbalanced <p> tags in default header/footer
These were broken by b70386a4 (Move the generated date from the top of
the page to the footer, 2014-05-31), which moved 'Generated ...' to
the footer with the opening tag, but didn't replace the blurb opening
tag or add a closing tag after 'Generated ...'.
2016-01-13 10:29:14 -04:00
W. Trevor King
8fc32dd42e nmbug-status: Style headers with smaller fonts
We only use h1 through h3, and David prefers smaller headers [1], so
shift over to the font sizes usually used for h2 through h4 [2,3,4].
I haven't bothered with the W3C's default margins, since a bit of
extra whitespace doesn't seem like a big deal.

[1]: id:87k2nl8r0k.fsf@zancas.localnet
     http://article.gmane.org/gmane.mail.notmuch.general/21595
[2]: http://www.w3.org/TR/html-markup/h2.html
[3]: http://www.w3.org/TR/html-markup/h3.html
[4]: http://www.w3.org/TR/html-markup/h4.html
2016-01-13 10:28:49 -04:00
W. Trevor King
e3d586d038 nmbug-status: Adjust headers to start with h1
We've been leading off with h2s since 3e5fb88f (contrib/nmbug: add
nmbug-status script, 2012-07-07), but the semantically-correct headers
are:

  <h1>{title}</h1>
  ...
  <h2>Views</h2>
  ...
  <h3>View 1</h3>
  ...
  <h3>View 2</h3>
  ...

We can always add additional CSS if the default h1 formatting is too
intense.
2016-01-13 10:28:38 -04:00
W. Trevor King
a07cafae00 nmbug-status: Avoid hard-coded filename in error message
We already have a 'filename' variable with the name, so stay DRY and
use that variable here.

Also fix a missing-whitespace error from bed8b674 (nmbug-status:
Clarify errors for illegible configs, 2014-05-10), wrapping on the
sentence to match similar error-generation earlier in this function.
2016-01-07 09:15:35 -04:00
Jani Nikula
018e69f558 nmbug-status: print config errors to stderr
Particularly scripted usage with stdout redirection can be confusing
if errors are printed to stdout instead of stderr.
2015-10-04 07:22:03 -03:00
Jani Nikula
8b35b8f71a nmbug-status: add support for specifying sort order for each view
Let each view have a "sort" key, typically used with values
"oldest-first" or "newest-first" (although all values in Query.SORT
are accepted), and sort the results accordingly. Oldest first remains
the default.

The dynamic approach of mapping sort values is as suggested by
W. Trevor King <wking@tremily.us>.
2015-09-29 08:25:25 -03:00
W. Trevor King
244f873954 nmbug-status: Use 'show-ref --heads' for loading configs
When loading configs from Git, the bare branch name (without a
refs/heads/ prefix or similar) matches all branches of that name
(including remote-tracking branches):

  .nmbug $ git show-ref config
  48f3bbf1d1492e5f3d2f01de6ea79a30d3840f20 refs/heads/config
  48f3bbf1d1492e5f3d2f01de6ea79a30d3840f20 refs/remotes/origin/config
  4b6dbd9ffd152e7476f5101eff26747f34497cee refs/remotes/wking/config

Instead of relying on the ordering of the matching references, use
--heads to ensure we only match local branches.
2015-04-01 06:16:06 +02:00
W. Trevor King
bed8b6743d nmbug-status: Clarify errors for illegible configs
Carl Worth pointed out that errors like:

  $ ./nmbug-status
  fatal: Not a git repository: '/home/cworth/.nmbug'
  fatal: Not a git repository: '/home/cworth/.nmbug'
  Traceback (most recent call last):
    File "./nmbug-status", line 254, in <module>
      config = read_config(path=args.config)
    File "./nmbug-status", line 73, in read_config
      return json.load(fp)
    File "/usr/lib/python2.7/json/__init__.py", line 290, in load
      **kw)
    File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
      return _default_decoder.decode(s)
    File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
      raise ValueError("No JSON object could be decoded")
  ValueError: No JSON object could be decoded

are not particularly clear.  With this commit, we'll get output like:

  $ ./nmbug-status
  fatal: Not a git repository: '/home/wking/.nmbug'
  No local branch 'config' in /home/wking/.nmbug.  Checkout a local
  config branch or explicitly set --config.

which is much more accessible.  I've also added user-friendly messages
for a number of other config-parsing errors.
2015-03-15 09:28:15 +01:00
W. Trevor King
9d25c97d8b nmbug: Add a 'help' command for folks who don't like --help
The 'if args.func == help' block at the end avoids:

    AttributeError: 'functools.partial' object has no attribute '__code__'
2015-01-18 11:00:51 +01:00
W. Trevor King
7f2cb3be4e nmbug: Translate to Python
This allows us to capture stdout and stderr separately, and do other
explicit subprocess manipulation without resorting to external
packages.  It should be compatible with Python 2.7 and later
(including the 3.x series).

Most of the user-facing interface is the same, but there are a few
changes, where reproducing the original interface was too difficult or
I saw a change to make the underlying Git UI accessible:

* 'nmbug help' has been split between the general 'nmbug --help' and
  the command-specific 'nmbug COMMAND --help'.

* Commands are no longer split into "most common", "other useful", and
  "less common" sets.  If we need something like this, I'd prefer
  workflow examples highlighting common commands in the module
  docstring (available with 'nmbug --help').

* 'nmbug commit' now only uses a single argument for the optional
  commit-message text.  I wanted to expose more of the underlying 'git
  commit' UI, since I personally like to write my commit messages in
  an editor with the notes added by 'git commit -v' to jog my memory.
  Unfortunately, we're using 'git commit-tree' instead of 'git
  commit', and commit-tree is too low-level for editor-launching.  I'd
  be interested in rewriting commit() to use 'git commit', but that
  seemed like it was outside the scope of this rewrite.  So I'm not
  supporting all of Git's commit syntax in this patch, but I can at
  least match 'git commit -m MESSAGE' in requiring command-line commit
  messages to be a single argument.

* The default repository for 'nmbug push' and 'nmbug fetch' is now the
  current branch's upstream (branch.<name>.remote) instead of
  'origin'.  When we have to, we extract this remote by hand, but
  where possible we just call the Git command without a repository
  argument, and leave it to Git to figure out the default.

* 'nmbug push' accepts multiple refspecs if you want to explicitly
  specify what to push.  Otherwise, the refspec(s) pushed depend on
  push.default.  The Perl version hardcoded 'master' as the pushed
  refspec.

* 'nmbug pull' defaults to the current branch's upstream
  (branch.<name>.remote and branch.<name>.merge) instead of hardcoding
  'origin' and 'master'.  It also supports multiple refspecs if for
  some crazy reason you need an octopus merge (but mostly to avoid
  breaking consistency with 'git pull').

* 'nmbug log' now execs 'git log', as there's no need to keep the
  Python process around once we've launched Git there.

* 'nmbug status' now catches stderr, and doesn't print errors like:

    No upstream configured for branch 'master'

  The Perl implementation had just learned to avoid crashing on that
  case, but wasn't yet catching the dying subprocess's stderr.

* 'nmbug archive' now accepts positional arguments for the tree-ish
  and additional 'git archive' options.  For example, you can run:

    $ nmbug archive HEAD -- --format tar.gz

  I wish I could have preserved the argument order from 'git archive'
  (with the tree-ish at the end), but I'm not sure how to make
  argparse accept arbitrary possitional arguments (some of which take
  arguments).  Flipping the order to put the tree-ish first seemed
  easiest.

* 'nmbug merge' and 'pull' no longer checkout HEAD before running
  their command, because blindly clobbering the index seems overly
  risky.

* In order to avoid creating a dirty index, 'nmbug commit' now uses
  the default index (instead of nmbug.index) for composing the commit.
  That way the index matches the committed tree.  To avoid leaving a
  broken index after a failed commit, I've wrapped the whole thing in
  a try/except block that resets the index to match the pre-commit
  treeish on errors.  That means that 'nmbug commit' will ignore
  anything you've cached in the index via direct Git calls, and you'll
  either end up with an index matching your notmuch tags and the new
  HEAD (after a successful commit) or an index matching the original
  HEAD (after a failed commit).
2014-10-05 07:16:29 +02:00
W. Trevor King
567aab405b nmbug: Handle missing @upstream in is_unmerged
If we don't have an upstream, there is nothing to merge, so nothing is
unmerged.  This avoids errors like:

  $ nmbug status
  error: No upstream configured for branch 'master'
  error: No upstream configured for branch 'master'
  fatal: ambiguous argument '@{upstream}': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'
  'git rev-parse @{upstream}' exited with nonzero value

You might not have an upstream if you're only using nmbug locally to
version-control your tags.
2014-07-16 19:31:28 -03:00
W. Trevor King
4697e86a52 nmbug: Add a git_with_status helper function
Sometimes we want to catch Git errors and handle them, instead of
dying with an error message.  This lower-level version of git() allows
us to get the error status when we want it.
2014-07-16 06:31:23 -03:00
W. Trevor King
7f2bbe93a5 nmbug-status: Optionally load the header and footer templates from the config
For folks that don't like the default templates for whatever reason.
2014-07-15 20:15:23 -03:00
W. Trevor King
f10024f30d nmbug-status: Add the time to the footer's build-date
Our repository [1] has a post-update hook that rebuilds the status
page after each push.  Since that may happen several times a day, we
might as well show the build time (as well as the date) in the footer.

The trailing 'Z' is the ISO 8601 designator for UTC.  Now that we're
showing times, it's nice to be explicit about the timezone we're
using.

The rename from date -> datetime gives us backward-compatibility for
folks that *do* only want the date.  We keep the old date formatting
to support those folks.

[1]: http://nmbug.tethera.net/git/nmbug-tags.git
2014-07-15 20:08:39 -03:00
W. Trevor King
7832258468 nmbug-status: Factor out header/footer context into a shared dict
Rather than splitting this context into header-only and footer-only
groups, just dump it all in a shared dict.  This will make it easier
to eventually split the header/footer templates out of this script
(e.g. if we want to load them from the config file).
2014-07-15 20:08:24 -03:00
Carl Worth
b70386a4cb Move the generated date from the top of the page to the footer.
It's useful reference information, but anyone who wants it will look
for and find it.  We don't need this front-and-center.  Follow the
pattern set by our header template with a triple-quoted string.

The gray <hr> styling is less agressive.  IE uses 'color' for drawing
the rule, while Gecko and Opera use the border or 'background-color'
[1].

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=239386
2014-07-15 20:07:18 -03:00
Carl Worth
b5bdf5f4a8 Add a docstring describing the program
Prefer a docstring to a header comment so we can use it as the
ArgumentParser description (formatted with 'nmbug-status --help').
Script readers still have it near the top of the file.  Since it's a
docstring, use PEP 257's summary-line-and-body format [1].

[1]: http://legacy.python.org/dev/peps/pep-0257/#multi-line-docstrings
2014-07-15 20:07:06 -03:00
Carl Worth
d1d84cab1d Add explicit license information
It's nice to have for situations where this script is found outside of
the notmuch source repository (e.g. after being installed).
2014-07-15 20:06:59 -03:00
David Bremner
dd24fdd33a nmbug: mark repository as bare on clone
If a git repository is non-bare, and core.worktree is not set, git
tries to deduce the worktree. This deduction is not always helpful, e.g.

% git --git-dir=$HOME/.nmbug clean -f

would likely delete most of the files in the current directory
2014-04-15 17:20:19 -03:00
W. Trevor King
c200167426 nmbug: Add 'clone' and replace FETCH_HEAD with @{upstream}
With two branches getting fetched (master and config), the branch
referenced by FETCH_HEAD is ambiguous.  For example, I have:

  $ cat FETCH_HEAD
  41d7bfa7184cc93c9dac139d1674e9530799e3b0 \
    not-for-merge   branch 'config' of http://nmbug.tethera.net/git/nmbug-tags
  acd379ccb973c45713eee9db177efc530f921954 \
    not-for-merge   branch 'master' of http://nmbug.tethera.net/git/nmbug-tags

(where I wrapped the line by hand).  This means that FETCH_HEAD
references the config branch:

  $ git rev-parse FETCH_HEAD
  41d7bfa7184cc93c9dac139d1674e9530799e3b0

which breaks all of the FETCH_HEAD logic in nmbug (where FETCH_HEAD is
assumed to point to the master branch).

Instead of relying on FETCH_HEAD, use @{upstream} as the
remote-tracking branch that should be merged/diffed/integrated into
HEAD.  @{upstream} was added in Git v1.7.0 (2010-02-12) [1], so
relying on it should be fairly safe.  One tricky bit is that bare
repositories don't set upstream tracking branches by default:

  $ git clone --bare http://nmbug.tethera.net/git/nmbug-tags.git nmbug-bare
  $ cd nmbug-bare
  $ git remote show origin
  * remote origin
    Fetch URL: http://nmbug.tethera.net/git/nmbug-tags.git
    Push  URL: http://nmbug.tethera.net/git/nmbug-tags.git
    HEAD branch: master
    Local refs configured for 'git push':
      config pushes to config (up to date)
      master pushes to master (up to date)

While in a non-bare clone:

  $ git clone http://nmbug.tethera.net/git/nmbug-tags.git
  $ cd nmbug-tags
  $ git remote show origin
  * remote origin
    Fetch URL: http://nmbug.tethera.net/git/nmbug-tags.git
    Push  URL: http://nmbug.tethera.net/git/nmbug-tags.git
    HEAD branch: master
    Remote branches:
      config tracked
      master tracked
    Local branch configured for 'git pull':
      master merges with remote master
    Local ref configured for 'git push':
      master pushes to master (up to date)

From the clone docs [2]:

  --bare::
        Make a 'bare' Git repository…
        Also the branch heads at the remote are copied directly
        to corresponding local branch heads, without mapping
        them to `refs/remotes/origin/`.  When this option is
        used, neither remote-tracking branches nor the related
        configuration variables are created.

To use @{upstream}, we need to the local vs. remote-tracking
distinction, so this commit adds 'nmbug clone', replacing the
previously suggested --bare clone with a non-bare --no-checkout
--separate-git-dir clone into a temporary work directory.  After
which:

  $ git rev-parse @{upstream}
  acd379ccb973c45713eee9db177efc530f921954

gives us the master-branch commit.  Existing nmbug users will have to
run the configuration tweaks and re-fetch by hand.  If you don't have
any local commits, you could also blow away your NMBGIT repository and
re-clone from scratch:

  $ nmbug clone http://nmbug.tethera.net/git/nmbug-tags.git

Besides removing the ambiguity of FETCH_HEAD, this commit allows users
to configure which upstream branch they want nmbug to track via 'git
config', in case they want to change their upstream repository.

[1]: http://git.kernel.org/cgit/git/git.git/tree/Documentation/RelNotes/1.7.0.txt
[2]: http://git.kernel.org/cgit/git/git.git/tree/Documentation/git-clone.txt
2014-04-08 07:39:28 -03:00
Jani Nikula
87c2cd78fd nmbug-status: make output title and blurb configurable
Make nmbug-status more generally usable outside of nmbug by not
hardcoding notmuch related things.

This lets anyone publish html search views to mailing list messages
with a custom config file, independent of nmbug.
2014-03-23 08:33:34 -03:00
Jani Nikula
81a1aae2dc nmbug-status: parameterize title and blurb in the page header
Prepare for more general use.
2014-03-23 08:32:40 -03:00
Tomi Ollila
18d71908b2 nmbug-status: replace __values__() with values() in OrderedDict stub
Python dict() object does not have __values__() function which
OrderedDict().values() (the stub provided in nmbug-status) could call
to provide ordered list of values. By renaming this thinko to
values() will make our stub work as expected -- dict items listed out
in order those were added to the dictionary.
2014-02-21 21:12:45 -04:00
W. Trevor King
320d4a856e nmbug-status: Hardcode UTF-8 instead of using the user's locale
David [1] and Tomi [2] both feel that the user's choice of LANG is not
explicit enough to have such a strong effect on nmbug-status.  For
example, cron jobs usually default to LANG=C, and that is going to
give you ASCII output:

  $ LANG=C python -c 'import locale; print(locale.getpreferredencoding())'
  ANSI_X3.4-1968

Trying to print Unicode author names (and other strings) in that
encoding would crash nmbug-status with a UnicodeEncodeError.  To avoid
that, this patch hardcodes UTF-8, which can handle generic Unicode,
and is the preferred encoding (regardless of LANG settings) for
everyone who has chimed in on the list so far.  I'd prefer trusting
LANG, but in the absence of any users that prefer non-UTF-8 encodings
I'm fine with this approach.

While we could achieve the same effect on the output content by
dropping the previous patch (nmbug-status: Encode output using the
user's locale), Tomi also wanted UTF-8 hardcoded as the config-file
encoding [2].  Keeping the output encoding patch and then adding this
to hardcode both the config-file and output encodings at once seems
the easiest route, now that fd29d3f (nmbug-status: Decode Popen output
using the user's locale, 2014-02-10) has landed in master.

[1]: id="877g8z4v4x.fsf@zancas.localnet"
     http://article.gmane.org/gmane.mail.notmuch.general/17202
[2]: id="m2vbwj79lu.fsf@guru.guru-group.fi"
     http://article.gmane.org/gmane.mail.notmuch.general/17209
2014-02-14 21:45:07 -04:00
W. Trevor King
ffed8f2866 nmbug-status: Encode output using the user's locale
Instead of always writing UTF-8, allow the user to configure the
output encoding using their locale.  This is useful for previewing
output in the terminal, for poor souls that don't use UTF-8 locales
;).
2014-02-14 21:44:11 -04:00
W. Trevor King
0d563dae1d nmbug-status: Add inter-message padding
We already had the tbody with a blank row separating threads (which is
not colored); this commit adds a bit of spacing to separate messages
within a thread.  It will also add a bit of colored padding above the
first message and below the final message, but the main goal is to add
padding *between* two-row message blocks.

                                               <--- new padding
  thread-1, message-1, row-1  (class="message-first")
  thread-1, message-1, row-2  (class="message-last")
                                               <--- new padding
    spacer tbody with a blank row
                                               <--- new padding
  thread-2, message-1, row-1  (class="message-first")
  thread-2, message-1, row-2  (class="message-last")
                                               <--- new padding
                                               <--- new padding
  thread-2, message-2, row-1  (class="message-first")
  thread-2, message-2, row-2  (class="message-last")
                                               <--- new padding
2014-02-14 21:42:36 -04:00
W. Trevor King
1aa56c2ac5 nmbug-status: Color threads in HTML output
Add tbody sections so we don't have to color every row.  Multiple
tbody sections are allowed [1].  Use CSS 3's nth-child to handle
even/odd coloring (skipping the spacer rows) [2], which is supported
on the major browsers [3].

border-spacing is from CCS 2.1 [4,5].  I'm using it to avoid
whitespace between td cells.

border-radius is from CCS 3 [6,7].  I'm using it to make the colored
sections a bit less harsh.  I tried adding rounded borders to the
tbody itself doesn't work, but I couldn't get that to work without
setting the tbody's display to 'block'.  That rounded the corners, but
collapsed the cell spacing (e.g. columns were no longer aligned).
This commit's by-corner-td approach is not particularly elegant, but
it works.  The td padding entries just ensure that the cell body is
suitably far from the edges that it doesn't fall outside of the
rounded corners.

The doubled-braces are escapes from Python's str.format.

[1]: http://www.w3.org/TR/html5/tabular-data.html#the-table-element
[2]: http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
[3]: https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child#Browser_compatibility
[4]: http://www.w3.org/TR/CSS2/tables.html#propdef-border-spacing
[5]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-spacing#Browser_compatibility
[6]: http://www.w3.org/TR/css3-background/#the-border-radius
[7]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius#Browser_compatibility
2014-02-14 21:40:20 -04:00
W. Trevor King
aaa7f0d92e nmbug-status: Escape &, <, and > in HTML display data
'message-id' and 'from' now have sensitive characters escaped using
xml.sax.saxutils.escape [1].  The 'subject' data was already being
converted to a link into Gmane; I've escape()d that too, so it doesn't
need to be handled ain the same block as 'message-id' and 'from'.

This prevents broken HTML by if subjects etc. contain characters that
would otherwise be interpreted as HTML markup.

[1]: http://docs.python.org/3/library/xml.sax.utils.html#xml.sax.saxutils.escape
2014-02-14 08:29:33 -04:00
W. Trevor King
aa32d2579b nmbug-status: Use <code> and <p> markup where appropriate
* Wrap free text in <p> tags.
* Convert <blockquote> to <p><code> for query strings.
* Wrap message-id-term (id:"...") in <code>.

The <code> tags get nicer default markup (smaller monospace font) for
notmuch query terms [1].  The <p> tags don't have much effect without
attached CSS, but bare text (phrasing content [2]) in <body> (which
expects flow content [3,4]) feels wrong.

[1]: http://www.w3.org/TR/html5/text-level-semantics.html#the-code-element
[2]: http://www.w3.org/TR/html5/dom.html#phrasing-content-1
[3]: http://www.w3.org/TR/html5/dom.html#flow-content-1
[4]: http://www.w3.org/TR/html5/sections.html#the-body-element
2014-02-13 21:47:37 -04:00