forgejo/vendor/github.com/xanzy/go-gitlab
Jordan 5c092eb0ef
Add support for migrating from Gitlab (#9084)
* First stab at a Gitlab migrations interface.

* Modify JS to show migration for Gitlab

* Properly strip out #gitlab tag from repo name

* Working Gitlab migrations!
Still need to figure out how to hide tokens/etc from showing up in opts.CloneAddr

* Try #2 at trying to hide credentials.
CloneAddr was being used as OriginalURL.
Now passing OriginalURL through from the form and saving it.

* Add go-gitlab dependency

* Vendor go-gitlab

* Use gitlab.BasicAuthClient
Correct CloneURL.
This should be functioning!
Previous commits fixed "Migrated from"
from including the migration credentials.

* Replaced repoPath with repoID globally.
RepoID is grabbed in NewGitlabDownloader

* Logging touchup

* Properly set private repo status.
Properly set milestone deadline time.
Consistently use Gitlab username for 'Name'.

* Add go-gitlab vendor cache

* Fix PR migrations:
- Count of issues is kept to set a non-conflicting PR.ID
- Bool is used to tell whether to fetch Issue or PR comments

* Ensure merged PRs are closed and set with the proper time

* Remove copyright and some commented code

* Rip out '#gitlab' based self-hosted Gitlab support

* Hide given credentials for migrated repos.

CloneAddr was being saved as OriginalURL.

Now passing OriginalURL through from the form and
saving it in it's place

* Use asset.URL directly, no point in parsing.
Opened PRs should fall through to false.

* Fix importing Milestones.
Allow importing using Personal Tokens or anonymous access.

* Fix Gitlab Milestone migration if DueDate isn't set

* Empty Milestone due dates properly return nil, not zero time

* Add GITLAB_READ_TOKEN to drone unit-test step

* Add working gitlab_test.go.
A Personal Access Token, given in env variable GITLAB_READ_TOKEN
is required to run the test.

* Fix linting issues

* Add modified JS files

* Remove pre-build JS files

* Only merged PRs are marged as merged/closed

* Test topics

* Skip test if gitlab is inaccessible

* Grab personal token from username, not password.
Matches Github migration implementation

* Add SetContext() to GitlabDownloader.

* Checking Updated field in Issues.

* Actually fetch Issue Updated time from Gitlab

* Add Gitlab migration GetReviews() stub

* Fix Patch and Clone URLs

* check Updated too

* fix mod

* make vendor with go1.14

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-19 23:44:11 +08:00
..
.gitignore Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
.travis.yml Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
access_requests.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
award_emojis.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
boards.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
branches.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
broadcast_messages.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
CHANGELOG.md Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
ci_yml_templates.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
commits.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
custom_attributes.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
deploy_keys.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
deployments.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
discussions.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
environments.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
epics.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
event_parsing.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
event_types.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
events.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
feature_flags.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
gitignore_templates.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
gitlab.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
go.mod Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
go.sum Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
group_badges.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
group_boards.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
group_clusters.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
group_labels.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
group_members.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
group_milestones.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
group_variables.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
groups.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
issue_links.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
issues.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
jobs.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
keys.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
labels.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
LICENSE Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
license.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
license_templates.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
merge_request_approvals.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
merge_requests.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
milestones.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
namespaces.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
notes.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
notifications.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
pages_domains.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
pipeline_schedules.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
pipeline_triggers.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
pipelines.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
project_badges.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
project_clusters.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
project_import_export.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
project_members.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
project_snippets.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
project_variables.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
projects.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
protected_branches.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
protected_tags.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
README.md Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
registry.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
releaselinks.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
releases.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
repositories.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
repository_files.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
resource_label_events.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
runners.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
search.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
services.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
settings.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
sidekiq_metrics.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
snippets.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
strings.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
system_hooks.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
tags.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
time_stats.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
todos.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
users.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
validate.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
version.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00
wikis.go Add support for migrating from Gitlab (#9084) 2020-04-19 23:44:11 +08:00

go-gitlab

A GitLab API client enabling Go programs to interact with GitLab in a simple and uniform way

Build Status GitHub license Sourcegraph GoDoc Go Report Card GitHub issues

NOTE

Release v0.6.0 (released on 25-08-2017) no longer supports the older V3 Gitlab API. If you need V3 support, please use the f-api-v3 branch. This release contains some backwards incompatible changes that were needed to fully support the V4 Gitlab API.

Coverage

This API client package covers most of the existing Gitlab API calls and is updated regularly to add new and/or missing endpoints. Currently the following services are supported:

  • Award Emojis
  • Branches
  • Broadcast Messages
  • Commits
  • Container Registry
  • Custom Attributes
  • Deploy Keys
  • Deployments
  • Discussions (threaded comments)
  • Environments
  • Epic Issues
  • Epics
  • Events
  • Feature Flags
  • Geo Nodes
  • GitLab CI Config Templates
  • Gitignores Templates
  • Group Access Requests
  • Group Issue Boards
  • Group Members
  • Group Milestones
  • Group-Level Variables
  • Groups
  • Issue Boards
  • Issues
  • Jobs
  • Keys
  • Labels
  • License
  • Merge Request Approvals
  • Merge Requests
  • Namespaces
  • Notes (comments)
  • Notification Settings
  • Open Source License Templates
  • Pages Domains
  • Pipeline Schedules
  • Pipeline Triggers
  • Pipelines
  • Project Access Requests
  • Project Badges
  • Project Clusters
  • Project Import/export
  • Project Members
  • Project Milestones
  • Project Snippets
  • Project-Level Variables
  • Projects (including setting Webhooks)
  • Protected Branches
  • Protected Tags
  • Repositories
  • Repository Files
  • Runners
  • Search
  • Services
  • Settings
  • Sidekiq Metrics
  • System Hooks
  • Tags
  • Todos
  • Users
  • Validate CI Configuration
  • Version
  • Wikis

Usage

import "github.com/xanzy/go-gitlab"

Construct a new GitLab client, then use the various services on the client to access different parts of the GitLab API. For example, to list all users:

git := gitlab.NewClient(nil, "yourtokengoeshere")
//git.SetBaseURL("https://git.mydomain.com/api/v4")
users, _, err := git.Users.ListUsers(&gitlab.ListUsersOptions{})

Some API methods have optional parameters that can be passed. For example, to list all projects for user "svanharmelen":

git := gitlab.NewClient(nil)
opt := &ListProjectsOptions{Search: gitlab.String("svanharmelen")}
projects, _, err := git.Projects.ListProjects(opt)

Examples

The examples directory contains a couple for clear examples, of which one is partially listed here as well:

package main

import (
	"log"

	"github.com/xanzy/go-gitlab"
)

func main() {
	git := gitlab.NewClient(nil, "yourtokengoeshere")

	// Create new project
	p := &gitlab.CreateProjectOptions{
		Name:                 gitlab.String("My Project"),
		Description:          gitlab.String("Just a test project to play with"),
		MergeRequestsEnabled: gitlab.Bool(true),
		SnippetsEnabled:      gitlab.Bool(true),
		Visibility:           gitlab.Visibility(gitlab.PublicVisibility),
	}
	project, _, err := git.Projects.CreateProject(p)
	if err != nil {
		log.Fatal(err)
	}

	// Add a new snippet
	s := &gitlab.CreateProjectSnippetOptions{
		Title:           gitlab.String("Dummy Snippet"),
		FileName:        gitlab.String("snippet.go"),
		Code:            gitlab.String("package main...."),
		Visibility:      gitlab.Visibility(gitlab.PublicVisibility),
	}
	_, _, err = git.ProjectSnippets.CreateSnippet(project.ID, s)
	if err != nil {
		log.Fatal(err)
	}
}

For complete usage of go-gitlab, see the full package docs.

ToDo

  • The biggest thing this package still needs is tests 😞

Issues

Author

Sander van Harmelen (sander@xanzy.io)

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0