Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Import commits from a private GitLab repository in an anonymized way.

License

NotificationsYou must be signed in to change notification settings

alexandear/import-gitlab-commits

Repository files navigation

Go Report Card

This tool imports commits from a private GitLab repository to a separate repository.It can be used to showcase your programming activity for another company on GitHub.

Check out this informative blog post for a practical use case on how to import GitLab commitshere.

Why It's Useful

Contributions before runningimport-gitlab-commits:

Screenshot of GitHub contributions graph before running import-gitlab-commits

After:

Screenshot of GitHub contributions graph after running import-gitlab-commits with a lot of activity

Getting Started

You can run the tool with Docker or a native Go build.

Docker Usage

Docker Compose

Run the tool using Docker Compose:

  1. Copy the environment variables template:

    cp .env.example .env
  2. Edit.env and configure your credentials.

  3. Build and run withDocker Compose:

docker compose up

The imported repository will be created in theoutput/ directory.

Plain Docker

Build:

docker build -t github.com/alexandear/import-gitlab-commits.

Run:

docker run --rm \    -e GITLAB_BASE_URL="https://gitlab.com" \    -e GITLAB_TOKEN="<your_gitlab_token>" \    -e COMMITTER_NAME="John Doe" \    -e COMMITTER_EMAIL="john.doe@example.com" \    -v$(pwd)/output:/root \    github.com/alexandear/import-gitlab-commits

Using native Go build

  1. Download and installGo.

  2. Install the program by running the following command in a shell:

    go install github.com/alexandear/import-gitlab-commits@latest
  3. Set environment variables and runimport-gitlab-commits:

    export GITLAB_BASE_URL=https://gitlab.comexport GITLAB_TOKEN=<your_gitlab_token>export COMMITTER_NAME="John Doe"export COMMITTER_EMAIL=john.doe@example.com$(go env GOPATH)/bin/import-gitlab-commits

Where$(go env GOPATH)/bin/ is the path whereimport-gitlab-commits is installed.

Configuration

Configure the tool with these environment variables:

  • GITLAB_BASE_URL - a GitLabinstance URL,e.g.,https://gitlab.com,https://gitlab.gnome.org, or any GitLab server.
  • GITLAB_TOKEN - a personalaccess token with these scopes:read_api,read_user,read_repository.
  • COMMITTER_NAME - your GitHub name with surname, e.g.,John Doe (can be passed togit config user.name).
  • COMMITTER_EMAIL - your GitHub email, e.g.,john.doe@example.com (valid forgit config user.email).

Internals

What the tool does:

  • Retrieves current user info usingGITLAB_TOKEN.
  • Fetches projects fromGITLAB_BASE_URL that the current user contributed to.
  • For all projects, fetches commits where the author's email matches the current user's email.
  • Creates a new repositoryrepo.gitlab.yourcompany.com.currentusername and commits all fetched commits with the message:Project: GITLAB_PROJECT_ID commit: GITLAB_COMMIT_HASH, commit dateGITLAB_COMMIT_DATE, and commit authorCOMMITTER_NAME <COMMITTER_EMAIL>.

To display the changes on GitHub, you need to:

  • Create a new repositoryyourcompany-contributions on GitHub.
  • Open the folderrepo.gitlab.yourcompany.com.currentusername.
  • Add the remote URL:git remote add origin git@github.com:username/yourcompany-contributions.git.
  • Push the changes.

Integration Tests

To run integration tests:

  1. Set theGITLAB_TOKEN environment variable with the value obtained athttps://gitlab.com/-/user_settings/personal_access_tokens. Necessary scopes:

    • read_api
    • read_user
    • read_repository
  2. SetGITLAB_BASE_URL tohttps://gitlab.com.

  3. Runmake test-integration.

About

Import commits from a private GitLab repository in an anonymized way.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp