From c201dc19da574c57446dd956602187e986f683b5 Mon Sep 17 00:00:00 2001 From: Jonathan Vahlsing Date: Sun, 17 May 2020 23:17:45 +0200 Subject: [PATCH 1/6] Fix typo breaking insecure option --- src/models/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/base.js b/src/models/base.js index a7ca006..4488564 100755 --- a/src/models/base.js +++ b/src/models/base.js @@ -20,7 +20,7 @@ class base { this._perPage = this.config ? this.config.get('_perPage') : 100; this._parallel = this.config ? this.config.get('_parallel') : 4; this._proxy = this.config && this.config.get('proxy') ? this.config.get('proxy') : undefined; - this._insecure = this.config && this.config.get('unsecure') ? this.config.get('unsecure') : false; + this._insecure = this.config && this.config.get('insecure') ? this.config.get('insecure') : false; } /** From a54d623bad94de228823981c33153055ce92e00d Mon Sep 17 00:00:00 2001 From: kris Date: Wed, 3 Jun 2020 09:53:18 +0200 Subject: [PATCH 2/6] Create CONTRIBUTING.md --- CONTRIBUTING.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ff6646f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,73 @@ +# Contributing + +## How to test the basic functions of gtt + +Create a new project on GitLab if you haven't done so already and write down the project path. e.g. `kriskbx/example-project`. To test groups and subgroups, create a new group with at least one subgroup. Add a new project to both the parent group (e.g. `example-group`) and the subgroup (e.g. `example-group/example-subgroup`) and write down the paths of all the projects and groups. Create at least two issues (write down their id e.g. `42`, `43`) and one merge request (e.g. `13`) in all projects. Then run the following basic commands and check that they work as expected: + +``` +# Test config command +gtt config + +# Test basic time tracking +gtt start "kriskbx/example-project" 42 +gtt stop +gtt log + +# Test cancelling +gtt start "kriskbx/example-project" 42 +gtt cancel +gtt log + +# Test merge request +gtt start --type=merge_request "kriskbx/example-project" 13 +gtt stop +gtt log + +# Test issue creation +gtt create "krisbxkbx/example-project" "New Issue" +gtt stop +gtt log + +# Test editing +gtt edit + +# Test deletion +gtt start "kriskbx/example-project" 42 +gtt stop +gtt delete + +# Test sync, check out issues on GitLab if changes are synced correctly +gtt sync + +# Test basic report +gtt report "kriskbx/example-project" + +# Test report for a single issue and multiple issues +gtt report "kriskbx/example-project" 42 +gtt report "kriskbx/example-project" 42 43 + +# Test report for a group +gtt report --type=group "example-group" +gtt report --type=group --subgroups "example-group" + +# Test combined reports +gtt report "kriskbx/example-project" "example-group/example-project" + +# Test outputs +gtt report --output=table "kriskbx/example-project" +gtt report --output=markdown "kriskbx/example-project" +gtt report --output=csv "kriskbx/example-project" +gtt report --output=pdf --file=test.pdf "kriskbx/example-project" +gtt report --output=xlsx --file=test.xlsx "kriskbx/example-project" + +# Test timeframes (adjust the values so it includes/excludes your issues) +gtt report --from="2020-06-02" --to="2020-06-03" "kriskbx/example-project" + +# Test filtering (you might need to add milestones, labels and additional stuff to properly test this) +gtt report --closed "kriskbx/example-project" +gtt report --user=username "kriskbx/example-project" +gtt report --milestone=milestone_name "kriskbx/example-project" +gtt report --include_by_labels=critical "kriskbx/example-project" +gtt report --exclude_by_labels=ignore "kriskbx/example-project" +gtt report --query=issues "kriskbx/example-project" +``` From c4692a54f64178bef9b9d43fe2d0c9b7683b44b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Walker=20Gusm=C3=A3o?= Date: Wed, 3 Jun 2020 06:08:04 -0300 Subject: [PATCH 3/6] Add pwd to docker container (#108) * add pwd * add pwd doc * add editor env --- Dockerfile | 5 ++++- documentation.md | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8259bb0..2d9509f 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,12 @@ FROM node:8.2.1-alpine ENV GTT_VERSION 1.7.39 +ENV EDITOR vi + +WORKDIR /pwd RUN yarn global add --prefix /usr/local "gitlab-time-tracker@$GTT_VERSION" -VOLUME ["/root"] +VOLUME ["/root", "/pwd"] ENTRYPOINT ["gtt"] CMD ["--help"] diff --git a/documentation.md b/documentation.md index 01a2e94..41fe224 100644 --- a/documentation.md +++ b/documentation.md @@ -70,12 +70,13 @@ you can use the official [Docker image](https://hub.docker.com/r/kriskbx/gitlab- docker run \ --rm -it \ -v ~:/root \ + -v $(pwd):/pwd \ kriskbx/gitlab-time-tracker \ --help ``` `--rm` removes the container after running, `-it` makes it interactive, `-v ~:/root` mounts your home directory to the -home directory inside the container. If you want to store the config in another place, mount another directory: +home directory inside the container, `-v $(pwd):/pwd` mounts current directory inside the container to gtt be able to read local config. If you want to store the config in another place, mount another directory: ```shell @@ -101,7 +102,7 @@ docker run \ I highly recommend creating an alias and adding it to your `bashrc`: ```shell -echo "alias gtt='docker run --rm -it -v ~:/root kriskbx/gitlab-time-tracker'" >>~/.bashrc +echo "alias gtt='docker run --rm -it -v ~:/root -v $(pwd):/pwd kriskbx/gitlab-time-tracker'" >>~/.bashrc ``` Now you can simply write `gtt` instead of the bulky Docker command before. Try it out: `gtt --help` From f3771088cf6915142ad81536c53142ca6eff9a6b Mon Sep 17 00:00:00 2001 From: Jean-Denis Caron Date: Sun, 7 Jun 2020 17:18:36 -0400 Subject: [PATCH 4/6] Fix rate limit of 600 requests per minutes on Gitlab.com (#106) This is a simple fix, maximum of 10 requests per seconds = maximum of 600 requests per minutes. It does slow down a bit the report but it prevent a fatal error. It's possible to design a more sophisticated fix but it will be more complex with more states to manage. It would be more prone to bugs. I favor simplicity over maximum speed. Co-authored-by: Jean-Denis Caron Co-authored-by: Ciprian Dobre-Trifan --- package.json | 1 + src/models/base.js | 11 ++++++----- yarn.lock | 5 +++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8dc55e8..9496a9c 100755 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "request-promise-native": "^1.0.4", "shelljs": "^0.8.3", "tempfile": "^2.0.0", + "throttled-queue": "^1.0.7", "underscore": "^1.9.1", "xdg-basedir": "^3.0.0", "xlsx": "^0.13.5" diff --git a/src/models/base.js b/src/models/base.js index 4488564..754aac5 100755 --- a/src/models/base.js +++ b/src/models/base.js @@ -2,6 +2,7 @@ const request = require('request-promise-native'); const url = require('url'); const async = require('async'); const crypto = require('crypto'); +const throttle = require('throttled-queue')(10, 1000); /** * base model @@ -35,7 +36,7 @@ class base { data.private_token = this.token; - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => throttle(() => { request.post(`${this.url}${path}`, { json: true, body: data, @@ -49,7 +50,7 @@ class base { if (this.config.get('_createDump')) this.setDump(response, key); resolve(response); }).catch(e => reject(e)); - }); + })); } /** @@ -66,7 +67,7 @@ class base { path += (path.includes('?') ? '&' : '?') + `private_token=${this.token}`; path += `&page=${page}&per_page=${perPage}`; - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => throttle(() => { request(`${this.url}${path}`, { json: true, insecure: this._insecure, @@ -79,7 +80,7 @@ class base { if (this.config.get('_createDump')) this.setDump(response, key); resolve(response); }).catch(e => reject(e)); - }); + })); } /** @@ -190,4 +191,4 @@ class base { } } -module.exports = base; \ No newline at end of file +module.exports = base; diff --git a/yarn.lock b/yarn.lock index 2da1b0d..8dfdeda 100755 --- a/yarn.lock +++ b/yarn.lock @@ -2429,6 +2429,11 @@ text-encoding@0.6.4, text-encoding@^0.6.4: version "0.6.4" resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" +throttled-queue@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/throttled-queue/-/throttled-queue-1.0.7.tgz#da7ed6702941993044a1c5fd2ac3a58582dd2977" + integrity sha512-/HT49S7m+NvdyJMoMRzIYlawKjeHn8jEc8TZaGmFi5IBu09hIiU/QoP1zcrB9X2qsVC11PgfRfqd8zEQs7PlEA== + throttleit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c" From ec5ca47d2e45f087dccb6bbdddc970935a61c256 Mon Sep 17 00:00:00 2001 From: kris Date: Wed, 10 Jun 2020 09:17:33 +0200 Subject: [PATCH 5/6] Update CONTRIBUTING.md --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff6646f..73931f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,9 @@ ## How to test the basic functions of gtt -Create a new project on GitLab if you haven't done so already and write down the project path. e.g. `kriskbx/example-project`. To test groups and subgroups, create a new group with at least one subgroup. Add a new project to both the parent group (e.g. `example-group`) and the subgroup (e.g. `example-group/example-subgroup`) and write down the paths of all the projects and groups. Create at least two issues (write down their id e.g. `42`, `43`) and one merge request (e.g. `13`) in all projects. Then run the following basic commands and check that they work as expected: +Create a new project on GitLab if you haven't done so already and write down the project path. e.g. `kriskbx/example-project`. To test groups and subgroups, create a new group with at least one subgroup. Add a new project to both the parent group (e.g. `example-group`) and the subgroup (e.g. `example-group/example-subgroup`) and write down the paths of all the projects and groups. Create at least two issues (write down their id e.g. `42`, `43`) and one merge request (e.g. `13`) in all projects. Or just use our public group over here: https://gitlab.com/gtt + +Then run the following basic commands and check that they work as expected: ``` # Test config command From f3022eb6ef3c695482a7915971e68cc122d8ac88 Mon Sep 17 00:00:00 2001 From: kris <3148865+kriskbx@users.noreply.github.com> Date: Thu, 22 May 2025 08:55:54 +0200 Subject: [PATCH 6/6] chore: add message about the projects status --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index f41da8d..bc99b29 100755 --- a/readme.md +++ b/readme.md @@ -8,6 +8,10 @@

+## ⚠️ Attention + +This repository is not maintained anymore. If you still want to use gtt and get regular updates, I recommend checking out this fork: https://github.com/ndu2/gitlab-time-tracker + ## introduction gtt is a fully featured command line interface for GitLab's time tracking feature. It monitors the time you spent on an issue or merge request locally and syncs it to GitLab. It also allows you to create reports in various formats from time tracking data stored on GitLab. **Looking for a graphical user interface? Check out the [gtt taskbar/menubar app](https://github.com/kriskbx/gitlab-time-tracker-taskbar) for Linux, Mac & Windows!**