Skip to content

Instantly share code, notes, and snippets.

@matoous
Created August 31, 2020 08:04
Show Gist options
  • Save matoous/c0d82a4f45a53c441ae035758b1fed84 to your computer and use it in GitHub Desktop.
Save matoous/c0d82a4f45a53c441ae035758b1fed84 to your computer and use it in GitHub Desktop.
#/bin/sh
if [[ -x $GIT_TOKEN ]]; then
echo "you need to set GIT_TOKEN env variable"
exit 1
fi
# get all merge requests for our team
# filter the merge request for only those that have time spent != null
curl https://gitlab.skypicker.com/api/v4/groups/search-team/merge_requests\?state\=all\&created_after\=$(date -v-1w +%Y/%m/%d)\&per_page\=100 --header "Private-Token: $GIT_TOKEN" -s \
| jq -c ".[] | select(.time_stats.human_total_time_spent != null) | { project_id: .project_id, id: .iid, title: .title }" \
| while read i; do
project_id=$(echo $i | jq ".project_id")
mr_id=$(echo $i | jq ".id")
title=$(echo $i | jq ".title")
echo "$title"
# get the notes on the MR and filter out only those that added time spent
curl -s https://gitlab.skypicker.com/api/v4/projects/$project_id/merge_requests/$mr_id/notes\?per_page\=100 --header "Private-Token: $GIT_TOKEN" \
| jq ".[] | select(.body | contains(\"time spent\")) | { time: .body, user: .author.username } | \"\(.user): \(.time)\""
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment