gitlabPatches

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: GPL-3.0 Imports: 9 Imported by: 1

README

gitlab-patches

does what is says on the tin

this tool helps you scrape the last x commits pushed to gitlab (and grab their patch files) using the gitlab api. It returns the patch URL, associated domains, repo type and more!

Usage

cd gitlab-patches-cli/

go run main.go

Usage of ./gitlab-patches:
  -output
        Save as line-separated JSON in a file (default file format: <01-01-2024-0>.json)
  -max int
        Maximum number of commits to grab from GitLab API
  -per int
        Results to grab per page from GitLab API

Examples

A list of the last X patches pushed to gitlab in json format

go run main.go --json

This can be combined with a service file or a cron to automate it.

Output
go run main.go --json

{"project_id":62541692,"project_name":"aphysica.gitlab.io","project_path":"aphysica.gitlab.io","project_namespace":"aphysica","project_web_url":"https://gitlab.com/aphysica/aphysica.gitlab.io","kind":"user","commit_id":"ea558b0ce600c0376c76c5f0261db47f1efe2195","commit_short_id":"ea558b0c","commit_title":"index","commit_message":"index","commit_created_at":"2024-10-14T00:09:37Z","commit_author_name":"aphysica","commit_patch_url":"https://gitlab.com/aphysica/aphysica.gitlab.io/-/commit/ea558b0ce600c0376c76c5f0261db47f1efe2195.patch","associated_domains":["gitlab.com"]}
{"project_id":62541798,"project_name":"shyameer - Security policy project","project_path":"shyameer-security-policy-project","project_namespace":"shyameer","project_web_url":"https://gitlab.com/shyamee11/shyameer-security-policy-project","kind":"group","commit_id":"e25c2a197d0a3c4d6ce871a8361304bdcdcbab88","commit_short_id":"e25c2a19","commit_title":"Initial commit","commit_message":"Initial commit","commit_created_at":"2024-10-14T00:12:03Z","commit_author_name":"tester bhai","commit_patch_url":"https://gitlab.com/shyamee11/shyameer-security-policy-project/-/commit/e25c2a197d0a3c4d6ce871a8361304bdcdcbab88.patch","associated_domains":null}
{"project_id":62541965,"project_name":"alphabet-soup","project_path":"alphabet-soup","project_namespace":"Colin Nguyen","project_web_url":"https://gitlab.com/colinn0803/alphabet-soup","kind":"user","commit_id":"523e8543d567390a63042f0dea4ef868f1c96e8c","commit_short_id":"523e8543","commit_title":"Minor README correction for input format.","commit_message":"Minor README correction for input format.","commit_created_at":"2019-04-29T13:47:07Z","commit_author_name":"Brett Meyers","commit_patch_url":"https://gitlab.com/colinn0803/alphabet-soup/-/commit/523e8543d567390a63042f0dea4ef868f1c96e8c.patch","associated_domains":["readme.md","eitccorp.com"]}
...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitlabCacheDir = ".gitlabCommits/"

Functions

This section is empty.

Types

type Commit

type Commit struct {
	ID         string    `json:"id"`
	ShortID    string    `json:"short_id"`
	Title      string    `json:"title"`
	Message    string    `json:"message"`
	CreatedAt  time.Time `json:"created_at"`
	AuthorName string    `json:"author_name"`
	PatchURL   string    `json:"patch_url"`
}

type MergedOutput

type MergedOutput struct {
	ProjectID         int       `json:"project_id"`
	ProjectName       string    `json:"project_name"`
	ProjectPath       string    `json:"project_path"`
	ProjectNamespace  string    `json:"project_namespace"`
	ProjectWebURL     string    `json:"project_web_url"`
	Kind              string    `json:"kind"`
	CommitID          string    `json:"commit_id"`
	CommitShortID     string    `json:"commit_short_id"`
	CommitTitle       string    `json:"commit_title"`
	CommitMessage     string    `json:"commit_message"`
	CommitCreatedAt   time.Time `json:"commit_created_at"`
	CommitAuthorName  string    `json:"commit_author_name"`
	CommitPatchURL    string    `json:"commit_patch_url"`
	AssociatedDomains []string  `json:"associated_domains"`
}

func GetGitlabCommits

func GetGitlabCommits(perPage int, maxCommits int) []MergedOutput

type Namespace

type Namespace struct {
	Name string `json:"name"`
	Kind string `json:"kind"`
}

type Project

type Project struct {
	ID        int       `json:"id"`
	Name      string    `json:"name"`
	Path      string    `json:"path"`
	Namespace Namespace `json:"namespace"`
	WebURL    string    `json:"web_url"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL