Skip to content

Commit c525031

Browse files
author
Adrián Escoms
committed
Merge branch 'master' of https://github.com/kriskbx/gitlab-time-tracker into kriskbx-master
# Conflicts: # Dockerfile # src/models/base.js
2 parents be958a2 + ec5ca47 commit c525031

File tree

5 files changed

+120
-42
lines changed

5 files changed

+120
-42
lines changed

CONTRIBUTING.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Contributing
2+
3+
## How to test the basic functions of gtt
4+
5+
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
6+
7+
Then run the following basic commands and check that they work as expected:
8+
9+
```
10+
# Test config command
11+
gtt config
12+
13+
# Test basic time tracking
14+
gtt start "kriskbx/example-project" 42
15+
gtt stop
16+
gtt log
17+
18+
# Test cancelling
19+
gtt start "kriskbx/example-project" 42
20+
gtt cancel
21+
gtt log
22+
23+
# Test merge request
24+
gtt start --type=merge_request "kriskbx/example-project" 13
25+
gtt stop
26+
gtt log
27+
28+
# Test issue creation
29+
gtt create "krisbxkbx/example-project" "New Issue"
30+
gtt stop
31+
gtt log
32+
33+
# Test editing
34+
gtt edit
35+
36+
# Test deletion
37+
gtt start "kriskbx/example-project" 42
38+
gtt stop
39+
gtt delete
40+
41+
# Test sync, check out issues on GitLab if changes are synced correctly
42+
gtt sync
43+
44+
# Test basic report
45+
gtt report "kriskbx/example-project"
46+
47+
# Test report for a single issue and multiple issues
48+
gtt report "kriskbx/example-project" 42
49+
gtt report "kriskbx/example-project" 42 43
50+
51+
# Test report for a group
52+
gtt report --type=group "example-group"
53+
gtt report --type=group --subgroups "example-group"
54+
55+
# Test combined reports
56+
gtt report "kriskbx/example-project" "example-group/example-project"
57+
58+
# Test outputs
59+
gtt report --output=table "kriskbx/example-project"
60+
gtt report --output=markdown "kriskbx/example-project"
61+
gtt report --output=csv "kriskbx/example-project"
62+
gtt report --output=pdf --file=test.pdf "kriskbx/example-project"
63+
gtt report --output=xlsx --file=test.xlsx "kriskbx/example-project"
64+
65+
# Test timeframes (adjust the values so it includes/excludes your issues)
66+
gtt report --from="2020-06-02" --to="2020-06-03" "kriskbx/example-project"
67+
68+
# Test filtering (you might need to add milestones, labels and additional stuff to properly test this)
69+
gtt report --closed "kriskbx/example-project"
70+
gtt report --user=username "kriskbx/example-project"
71+
gtt report --milestone=milestone_name "kriskbx/example-project"
72+
gtt report --include_by_labels=critical "kriskbx/example-project"
73+
gtt report --exclude_by_labels=ignore "kriskbx/example-project"
74+
gtt report --query=issues "kriskbx/example-project"
75+
```

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
FROM node:8.2.1-alpine
22

3-
ENV GTT_VERSION 1.7.40
3+
ENV GTT_VERSION 1.7.39
4+
ENV EDITOR vi
5+
6+
WORKDIR /pwd
47

58
RUN yarn global add --prefix /usr/local "gitlab-time-tracker@$GTT_VERSION"
69

7-
VOLUME ["/root"]
10+
VOLUME ["/root", "/pwd"]
811
ENTRYPOINT ["gtt"]
912
CMD ["--help"]

documentation.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,13 @@ you can use the official [Docker image](https://hub.docker.com/r/kriskbx/gitlab-
7070
docker run \
7171
--rm -it \
7272
-v ~:/root \
73+
-v $(pwd):/pwd \
7374
kriskbx/gitlab-time-tracker \
7475
--help
7576
```
7677

7778
`--rm` removes the container after running, `-it` makes it interactive, `-v ~:/root` mounts your home directory to the
78-
home directory inside the container. If you want to store the config in another place, mount another directory:
79+
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:
7980

8081

8182
```shell
@@ -101,7 +102,7 @@ docker run \
101102
I highly recommend creating an alias and adding it to your `bashrc`:
102103

103104
```shell
104-
echo "alias gtt='docker run --rm -it -v ~:/root kriskbx/gitlab-time-tracker'" >>~/.bashrc
105+
echo "alias gtt='docker run --rm -it -v ~:/root -v $(pwd):/pwd kriskbx/gitlab-time-tracker'" >>~/.bashrc
105106
```
106107

107108
Now you can simply write `gtt` instead of the bulky Docker command before. Try it out: `gtt --help`

src/models/base.js

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ const request = require('request-promise-native');
22
const url = require('url');
33
const async = require('async');
44
const crypto = require('crypto');
5-
const throttledQueue = require('throttled-queue');
6-
7-
const throttle = throttledQueue(10, 1000, true);
5+
const throttle = require('throttled-queue')(10, 1000);
86

97
/**
108
* base model
@@ -23,7 +21,7 @@ class base {
2321
this._perPage = this.config ? this.config.get('_perPage') : 100;
2422
this._parallel = this.config ? this.config.get('_parallel') : 4;
2523
this._proxy = this.config && this.config.get('proxy') ? this.config.get('proxy') : undefined;
26-
this._insecure = this.config && this.config.get('unsecure') ? this.config.get('unsecure') : false;
24+
this._insecure = this.config && this.config.get('insecure') ? this.config.get('insecure') : false;
2725
}
2826

2927
/**
@@ -38,23 +36,21 @@ class base {
3836

3937
data.private_token = this.token;
4038

41-
return new Promise((resolve, reject) => {
42-
throttle(() => {
43-
request.post(`${this.url}${path}`, {
44-
json: true,
45-
body: data,
46-
insecure: this._insecure,
47-
proxy: this._proxy,
48-
resolveWithFullResponse: true,
49-
headers: {
50-
'PRIVATE-TOKEN': this.token
51-
}
52-
}).then(response => {
53-
if (this.config.get('_createDump')) this.setDump(response, key);
54-
resolve(response);
55-
}).catch(e => reject(e));
56-
})
57-
});
39+
return new Promise((resolve, reject) => throttle(() => {
40+
request.post(`${this.url}${path}`, {
41+
json: true,
42+
body: data,
43+
insecure: this._insecure,
44+
proxy: this._proxy,
45+
resolveWithFullResponse: true,
46+
headers: {
47+
'PRIVATE-TOKEN': this.token
48+
}
49+
}).then(response => {
50+
if (this.config.get('_createDump')) this.setDump(response, key);
51+
resolve(response);
52+
}).catch(e => reject(e));
53+
}));
5854
}
5955

6056
/**
@@ -71,22 +67,20 @@ class base {
7167
path += (path.includes('?') ? '&' : '?') + `private_token=${this.token}`;
7268
path += `&page=${page}&per_page=${perPage}`;
7369

74-
return new Promise((resolve, reject) => {
75-
throttle(() => {
76-
request(`${this.url}${path}`, {
77-
json: true,
78-
insecure: this._insecure,
79-
proxy: this._proxy,
80-
resolveWithFullResponse: true,
81-
headers: {
82-
'PRIVATE-TOKEN': this.token
83-
}
84-
}).then(response => {
85-
if (this.config.get('_createDump')) this.setDump(response, key);
86-
resolve(response);
87-
}).catch(e => reject(e));
88-
})
89-
});
70+
return new Promise((resolve, reject) => throttle(() => {
71+
request(`${this.url}${path}`, {
72+
json: true,
73+
insecure: this._insecure,
74+
proxy: this._proxy,
75+
resolveWithFullResponse: true,
76+
headers: {
77+
'PRIVATE-TOKEN': this.token
78+
}
79+
}).then(response => {
80+
if (this.config.get('_createDump')) this.setDump(response, key);
81+
resolve(response);
82+
}).catch(e => reject(e));
83+
}));
9084
}
9185

9286
/**
@@ -197,4 +191,4 @@ class base {
197191
}
198192
}
199193

200-
module.exports = base;
194+
module.exports = base;

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,6 +2380,11 @@ [email protected], text-encoding@^0.6.4:
23802380
version "0.6.4"
23812381
resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19"
23822382

2383+
throttled-queue@^1.0.7:
2384+
version "1.0.7"
2385+
resolved "https://registry.yarnpkg.com/throttled-queue/-/throttled-queue-1.0.7.tgz#da7ed6702941993044a1c5fd2ac3a58582dd2977"
2386+
integrity sha512-/HT49S7m+NvdyJMoMRzIYlawKjeHn8jEc8TZaGmFi5IBu09hIiU/QoP1zcrB9X2qsVC11PgfRfqd8zEQs7PlEA==
2387+
23832388
throttleit@^1.0.0:
23842389
version "1.0.0"
23852390
resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c"

0 commit comments

Comments
 (0)