Skip to content

Commit

Permalink
config(debian); initial packaging attempt
Browse files Browse the repository at this point in the history
/spend 1h30
  • Loading branch information
Goutte committed Nov 11, 2023
1 parent fa937cd commit 65196e6
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 12 deletions.
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
git-spend (1.2.0-1) UNRELEASED; urgency=medium

* Initial release (Closes: TODO)

-- "Antoine Goutenoir" <[email protected]> Sat, 11 Nov 2023 09:45:17 +0100
212 changes: 212 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
Source: git-spend
Maintainer: Debian Go Packaging Team <[email protected]>
Uploaders: "Antoine Goutenoir" <[email protected]>
Section: golang
Testsuite: autopkgtest-pkg-go
Priority: optional
Build-Depends: debhelper-compat (= 13),
dh-golang,
golang-any
Standards-Version: 4.6.0
Vcs-Browser: https://salsa.debian.org/go-team/packages/git-spend
Vcs-Git: https://salsa.debian.org/go-team/packages/git-spend.git
Homepage: https://github.com/Goutte/git-spend
Rules-Requires-Root: no
XS-Go-Import-Path: github.com/Goutte/git-spend

Package: git-spend
Architecture: any
Depends: ${misc:Depends},
${shlibs:Depends}
Built-Using: ${misc:Built-Using}
Description: Sum the time-tracking "/spend" commands of git commit messages. (program)
git-spend : time tracker using git commit message commands
.
Purpose
.
Collect, addition and return all the /spend and /spent time-tracking
directives in git commit messages.
.
| This looks at the git log of the currently checked out branch of the
| working directory,
| and therefore requires git to be installed on your system.
.
By Example
.
Say you are in the directory of a project with one commit like so :
.
feat(crunch): implement a nice feature
.
Careful, it's still sharp.
/spend 10h30
.
Running:
.
$ git spend sum
.
would yield:
.
| 1 day 2 hours 30 minutes
.
Of course, *git-spend* really shines when you have multiple commits with
/spend commands that you want to tally and sum.
.
| 💡 You can use git-spend sum or git spend sum, they are equivalent.
.
Specifications
.
We assume 8 hours per day, 5 days per week, 4 weeks per month. *(like
Gitlab does)* These can be configured at runtime if needed, using
environment variables.
.
The **complete specification** can be found in the rules
(/gitime/gitime_test_data.yaml) of the test data, and in excruciating
detail in the grammar (/gitime/grammar.go).
.
The acceptance testing suite (/test/features.bats) also holds many usage
examples.
.
Usage
.
Go into your git-versioned project's directory:
.
cd <some git versioned project with commits using /spend directives>
.
and run:
.
git spend sum
.
| 2 days 1 hour 42 minutes
.
Or run git-spend from anywhere, but specify the --target directory (which
defaults to .):
.
git spend sum --target <some git versioned project dir>
.
| 2 days 1 hour 42 minutes
.
| ⛑ Use git spend sum --help or man git-spend-sum to see all the options.
| Meanwhile, let's look at some available options, below.
.
Format the output
.
You can get the spent time in a specific unit :
.
git spend sum --minutes
git spend sum --hours
git spend sum --days
.
| These values will always be rounded to integers, for convenience,
| although *git-spend* does understand floating point numbers in /spend
| directives.
.
Filter by commit authors
.
You can track the time of specified authors only, by name or email :
.
git spend sum --author Alice --author [email protected]
.
Exclude merge commits
.
You can also exclude merge commits :
.
git spend sum --no-merges
.
Restrict to a range of commits
.
You can restrict to a range of commits, using a commit hash, a tag, or
even HEAD~N.
.
git spend sum --since <ref> --until <ref>
.
For example, to get the time spent on the last 15 commits :
.
git spend sum --since HEAD~15
.
Or the time spent on a tag since previous tag :
.
git spend sum --since 0.1.0 --until 0.1.1
.
You can also use *dates* and *datetimes*, but remember to quote them if
you specify the time:
.
git spend sum --since 2023-03-21
git spend sum --since "2023-03-21 13:37:00"
.
| 📅 Other supported time formats: RFC3339 (https://www.rfc-
| editor.org/rfc/rfc3339), RFC822
(https://www.w3.org/Protocols/rfc822/),
| RFC850 (https://www.rfc-editor.org/rfc/rfc850).
| If you need a specific timezone, try setting the TZ environment
| variable:
| TZ="Europe/Paris" git-spend sum --since 2023-03-21
.
Download
.
Direct download
.
You can ⮋ download the binary (https://github.com/Goutte/git-
spend/releases/latest/download/git-spend) straight from the latest build
in the releases (https://github.com/Goutte/git-spend/releases), and move
it anywhere in your $PATH, such as /usr/local/bin/git-spend for example.
.
| ⚠ Remember to enable the execution bit with chmod u+x ./git-spend, for
| example.
.
There is an *experimental* install script that does exactly this, plus
man pages generation:
.
curl https://raw.githubusercontent.com/Goutte/git-spend/main/install.sh
| sh
.
| 🐧 This script only works for linux/amd64, for now. *Stigmergy?*
.
Via go get
.
You can also install via go get (hopefully) :
.
go get -u github.com/goutte/git-spend
.
or go install:
.
go install github.com/goutte/git-spend
.
| If that fails, you can install by cloning and running make install.
.
Advanced Usage
.
Read from standard input
.
You can also directly parse messages from stdin instead of attempting to
read the git log:
.
git log > git.log
cat git.log | git-spend sum --stdin
.
| git spend ignores standard input otherwise.
.
Configure the time modulo
.
If you live somewhere where work hours per week are limited (to 35 for
example) in order to mitigate labor oppression tactics from monopoly
hoarders, you can use environment variables to control how time is
"rolled over" between units :
.
GIT_SPEND_HOURS_IN_ONE_DAY=7 git-spend sum
.
Here are the available environment variables :
.
* GIT_SPEND_MINUTES_IN_ONE_HOUR (default: 60)
* GIT_SPEND_HOURS_IN_ONE_DAY (default: 8)
* GIT_SPEND_DAYS_IN_ONE_WEEK (default: 5)
* GIT_SPEND_WEEKS_IN_ONE_MONTH (default: 4)
.
Install the man pages
.
If you installed via direct download, you might want to install the man
pages:
.
sudo git spend man --install
.
| git help spend will then work as expected.

32 changes: 32 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: git-spend
Upstream-Contact: "Antoine Goutenoir" <[email protected]>
Source: https://github.com/Goutte/git-spend

Files: *
Copyright: 2023 Antoine Goutenoir <[email protected]>
License: MIT

Files: debian/*
Copyright: 2023 Antoine Goutenoir <[email protected]>
License: MIT
Comment: Debian packaging is licensed under the same terms as upstream

License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions debian/gbp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[DEFAULT]
debian-branch = debian/sid
dist = DEP14
6 changes: 6 additions & 0 deletions debian/gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# auto-generated, DO NOT MODIFY.
# The authoritative copy of this file lives at:
# https://salsa.debian.org/go-team/infra/pkg-go-tools/blob/master/config/gitlabciyml.go
---
include:
- https://salsa.debian.org/go-team/infra/pkg-go-tools/-/raw/master/pipeline/test-archive.yml
7 changes: 7 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/make -f

%:
dh $@ --builddirectory=_build --buildsystem=golang --with=golang

override_dh_auto_install:
dh_auto_install -- --no-source
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
5 changes: 5 additions & 0 deletions debian/upstream/metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
Bug-Database: https://github.com/Goutte/git-spend/issues
Bug-Submit: https://github.com/Goutte/git-spend/issues/new
Repository: https://github.com/Goutte/git-spend.git
Repository-Browse: https://github.com/Goutte/git-spend
4 changes: 4 additions & 0 deletions debian/watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version=4
opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%@PACKAGE@-$1.tar.gz%,\
uversionmangle=s/(\d)[_\.\-\+]?(RC|rc|pre|dev|beta|alpha)[.]?(\d*)$/$1~$2$3/" \
https://github.com/Goutte/git-spend/tags .*/v?(\d\S*)\.tar\.gz debian
14 changes: 2 additions & 12 deletions packaging/debian/itp-git-spend.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
From: "Antoine Goutenoir" <[email protected]>
To: [email protected]
Subject: ITP: git-spend -- Sum the time-tracking "/spend" commands of git commit messages.
Subject: ITP: git-spend -- Sum the time-tracking /spend commands of git commit messages.
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Debbugs-CC: [email protected], [email protected]

Package: git-spend
Package: wnpp
Severity: wishlist
Owner: "Antoine Goutenoir" <[email protected]>

Expand Down Expand Up @@ -243,13 +243,3 @@ Owner: "Antoine Goutenoir" <[email protected]>
.
| There's an example in the Makefile (/Makefile), with the recipe make
| build-windows-amd64.
.
Contribute
.
Merge requests are welcome. Make sure you record the time you /spend in
your commit messages. :)
.
Translations
.
Translations files are in locale/*.toml. To add another language, add a
new file, some sugar, some water, and … *voilà !*

0 comments on commit 65196e6

Please sign in to comment.