Bash doesn't natively support querying GitLab (or any API) in a complex way. Generally, the GitLab API should be accessed with a language that has more advanced data processing capabilities.
But you can use curl to get the information you want from the GitLab API, then use jq to parse the JSON format. Here's an example of how you might do it:
TOKEN="YOUR_GITLAB_TOKEN"; USERNAME="TARGET_USERNAME"; curl --header "PRIVATE-TOKEN: $TOKEN" "https://gitlab.com/api/v4/users/$USERNAME/projects" | jq -r '.[] | .id' | xargs -I {} curl --header "PRIVATE-TOKEN: $TOKEN" "https://gitlab.com/api/v4/projects/{}/repository/commits" | jq -r '.[] | "\(.message) \(.web_url) \(.committed_date)"'
This is a simple one-liner, but it has several parts:
TOKEN="YOUR_GITLAB_TOKEN"; USERNAME="TARGET_USERNAME"; Replace "YOUR_GITLAB_TOKEN" and "TARGET_USERNAME" with your actual GitLab private token and target GitLab username.
curl --header "PRIVATE-TOKEN: $TOKEN" "https://gitlab.com/api/v4/users/$USERNAME/projects" This gets a list of all projects the user is involved in.
jq -r '.[] | .id' parses the JSON response to get all the project IDs.
xargs -I {} curl --header "PRIVATE-TOKEN: $TOKEN" "https://gitlab.com/api/v4/projects/{}/repository/commits" uses the project IDs to get all commits for each project.
- `jq -r '.[] | "(.message) (.web_url) (.committed_date)"' parses the JSON response to get the commit message, web URL (which includes the repo), and date of the commit.
Note: The above command will only list commits of the given user if they are the latest commit in each of their projects, because of the limitation of the GitLab's commit API. If you need to list all commits from a user, you may need to clone the repositories and use local git commands, or use a more complex script.