### Install go-bitbucket Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/ktrysmt/go-bitbucket/README.md Use 'go get' to install the go-bitbucket library. ```sh go get github.com/ktrysmt/go-bitbucket ``` -------------------------------- ### Install ghinstallation Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/bradleyfalzon/ghinstallation/v2/README.md Get the package using go get. ```bash go get -u github.com/bradleyfalzon/ghinstallation/v2 ``` -------------------------------- ### Install Afero Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/afero/README.md Install the Afero library using go get. ```bash go get github.com/spf13/afero ``` -------------------------------- ### Install go-version Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/hashicorp/go-version/README.md Install the go-version library using the standard go get command. ```bash $ go get github.com/hashicorp/go-version ``` -------------------------------- ### Install color package Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/fatih/color/README.md Use 'go get' to install the color package. ```bash go get github.com/fatih/color ``` -------------------------------- ### Start-ee.sh Example: Full Custom Configuration Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Provides a comprehensive example of configuring all optional arguments for the start-ee.sh script, allowing for complete control over the test environment setup. ```bash ./start-ee.sh true true latest /tmp/gitlab-data gitlab.local http://gitlab.local /tmp/ghorg ``` -------------------------------- ### Start Gitea Script Examples Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitea/README.md Illustrates various ways to invoke the `start.sh` script, from default behavior to fully customized configurations for different testing needs. ```bash # Default behavior - run tests and clean up ./start.sh # Keep Gitea running after tests for debugging ./start.sh false # Use specific Gitea version and keep it running ./start.sh false false 1.20.0 # Full custom configuration ./start.sh true true latest /tmp/gitea-data gitea.local http://gitea.local:3000 /tmp/ghorg ``` -------------------------------- ### Install go-colorable Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/mattn/go-colorable/README.md Install the go-colorable package using the go get command. ```bash $ go get github.com/mattn/go-colorable ``` -------------------------------- ### Manual Setup Instructions for Bitbucket Server Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-bitbucket/README.md Displays the necessary steps to manually set up Bitbucket Server after it has started via Docker. This includes accessing the web UI, creating an admin user, and entering a license key. ```text 🔧 MANUAL SETUP REQUIRED ======================================== Bitbucket Server is now running at: http://bitbucket.example.com:7990 Please complete the setup manually: 1. Open http://bitbucket.example.com:7990 in your browser - Create admin user with credentials: Username: admin Password: admin Email: admin@bitbucket.local 1. Enter your Bitbucket Data Center license key 1. Complete setup Once setup is complete, press ENTER to continue with seeding and testing... ``` -------------------------------- ### Install mapstructure Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/go-viper/mapstructure/v2/README.md Use 'go get' to install the mapstructure library. ```shell go get github.com/go-viper/mapstructure/v2 ``` -------------------------------- ### Install Locafero Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/sagikazarmark/locafero/README.md Use this command to install the Locafero library using go get. ```shell go get github.com/sagikazarmark/locafero ``` -------------------------------- ### Install Cobra Library Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/cobra/README.md Use 'go get' to install the latest version of the Cobra library. ```go go get -u github.com/spf13/cobra@latest ``` -------------------------------- ### Install go-colorful Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/lucasb-eyer/go-colorful/README.md Install the go-colorful library using the go get command. The package can then be imported into your Go projects. ```bash go get github.com/lucasb-eyer/go-colorful ``` -------------------------------- ### Create Project and Snippet Example Source: https://github.com/gabrie30/ghorg/blob/master/vendor/gitlab.com/gitlab-org/api/client-go/README.md Demonstrates creating a new project and then adding a snippet to that project. This example requires a valid GitLab token and shows how to set project and snippet options. ```go package main import ( "log" "gitlab.com/gitlab-org/api/client-go" ) func main() { git, err := gitlab.NewClient("yourtokengoeshere") if err != nil { log.Fatalf("Failed to create client: %v", err) } // Create new project p := &gitlab.CreateProjectOptions{ Name: gitlab.Ptr("My Project"), Description: gitlab.Ptr("Just a test project to play with"), MergeRequestsAccessLevel: gitlab.Ptr(gitlab.EnabledAccessControl), SnippetsAccessLevel: gitlab.Ptr(gitlab.EnabledAccessControl), Visibility: gitlab.Ptr(gitlab.PublicVisibility), } project, _, err := git.Projects.CreateProject(p) if err != nil { log.Fatal(err) } // Add a new snippet s := &gitlab.CreateProjectSnippetOptions{ Title: gitlab.Ptr("Dummy Snippet"), FileName: gitlab.Ptr("snippet.go"), Content: gitlab.Ptr("package main...."), Visibility: gitlab.Ptr(gitlab.PublicVisibility), } _, _, err = git.ProjectSnippets.CreateSnippet(project.ID, s) if err != nil { log.Fatal(err) } } ``` -------------------------------- ### Install Spinner Package Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/briandowns/spinner/README.md Use 'go get' to install the spinner package. This command fetches and installs the specified Go package. ```bash go get github.com/briandowns/spinner ``` -------------------------------- ### Install mapstructure Go Library Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/mitchellh/mapstructure/README.md Use standard go get to install the mapstructure library. ```bash go get github.com/mitchellh/mapstructure ``` -------------------------------- ### Integration Tests Script Examples Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitea/README.md Shows examples of how to run the `integration-tests.sh` script, including using default values and providing custom parameters. ```bash # Use defaults ./integration-tests.sh # Custom parameters ./integration-tests.sh "/tmp/ghorg" "my-token" "http://gitea.local:3000" ``` -------------------------------- ### Start and Stop Spinner Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/briandowns/spinner/README.md Demonstrates the basic usage of creating, starting, and stopping a spinner. Ensure to import the necessary packages and time for simulation. ```Go package main import ( "github.com/briandowns/spinner" "time" ) func main() { s := spinner.New(spinner.CharSets[9], 100*time.Millisecond) // Build our new spinner s.Start() // Start the spinner time.Sleep(4 * time.Second) // Run for some time to simulate work s.Stop() } ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/gabrie30/ghorg/blob/master/vendor/gitlab.com/gitlab-org/api/client-go/CONTRIBUTING.md Run this command to install all necessary dependencies for local development. ```sh make setup ``` -------------------------------- ### Example Repository Input Source: https://github.com/gabrie30/ghorg/blob/master/skills/ghorg-create-workspace/SKILL.md List repositories to include in the workspace, one per line. Press enter on an empty line when finished. ```text repo-one repo-two repo-three ``` -------------------------------- ### Install go.yaml.in/yaml/v3 Source: https://github.com/gabrie30/ghorg/blob/master/vendor/go.yaml.in/yaml/v3/README.md Run this command to install the package. The import path is go.yaml.in/yaml/v3. ```bash go get go.yaml.in/yaml/v3 ``` -------------------------------- ### Install GitLab API Client for Go Source: https://github.com/gabrie30/ghorg/blob/master/vendor/gitlab.com/gitlab-org/api/client-go/README.md Command to install the GitLab API client library for Go using the go get command. ```go go get gitlab.com/gitlab-org/api/client-go ``` -------------------------------- ### Install Viper Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/viper/README.md Install Viper using go get. Note that Viper uses Go Modules for dependency management. ```shell go get github.com/spf13/viper ``` -------------------------------- ### Run Individual Components Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Examples demonstrating how to run the seed and integration test scripts individually with their arguments. ```bash # Seed GitLab instance only ./seed.sh "password" "http://gitlab.example.com" "${HOME}/ghorg" ``` ```bash # Run integration tests only (assumes seeded instance) ./integration-tests.sh "${HOME}/ghorg" "password" "http://gitlab.example.com" ``` -------------------------------- ### Install Emoji Package Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/kyokomi/emoji/v2/README.md Use 'go get' to install the emoji v2 package. ```bash go get github.com/kyokomi/emoji/v2 ``` -------------------------------- ### Install the Graphemes Package Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/clipperhouse/uax29/v2/graphemes/README.md Use 'go get' to add the graphemes package to your project. ```bash go get github.com/clipperhouse/uax29/v2/graphemes ``` -------------------------------- ### Comprehensive Image Manipulation Example in Go Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/disintegration/imaging/README.md This example demonstrates opening, cropping, resizing, blurring, grayscaling, adjusting contrast and sharpness, inverting, embossing, pasting, and saving images using the imaging library. ```go package main import ( "image" "image/color" "log" "github.com/disintegration/imaging" ) func main() { // Open a test image. src, err := imaging.Open("testdata/flowers.png") if err != nil { log.Fatalf("failed to open image: %v", err) } // Crop the original image to 300x300px size using the center anchor. src = imaging.CropAnchor(src, 300, 300, imaging.Center) // Resize the cropped image to width = 200px preserving the aspect ratio. src = imaging.Resize(src, 200, 0, imaging.Lanczos) // Create a blurred version of the image. img1 := imaging.Blur(src, 5) // Create a grayscale version of the image with higher contrast and sharpness. img2 := imaging.Grayscale(src) img2 = imaging.AdjustContrast(img2, 20) img2 = imaging.Sharpen(img2, 2) // Create an inverted version of the image. img3 := imaging.Invert(src) // Create an embossed version of the image using a convolution filter. img4 := imaging.Convolve3x3( src, [9]float64{ -1, -1, 0, -1, 1, 1, 0, 1, 1, }, nil, ) // Create a new image and paste the four produced images into it. dst := imaging.New(400, 400, color.NRGBA{0, 0, 0, 0}) dst = imaging.Paste(dst, img1, image.Pt(0, 0)) dst = imaging.Paste(dst, img2, image.Pt(0, 200)) dst = imaging.Paste(dst, img3, image.Pt(200, 0)) dst = imaging.Paste(dst, img4, image.Pt(200, 200)) // Save the resulting image as JPEG. err = imaging.Save(dst, "testdata/out_example.jpg") if err != nil { log.Fatalf("failed to save image: %v", err) } } ``` -------------------------------- ### Start Bitbucket Server Component Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-bitbucket/README.md Starts only the Bitbucket Server Docker container without running tests. Useful for performing manual setup or debugging. ```bash ./run.sh latest /tmp/bitbucket-data bitbucket.example.com false ``` -------------------------------- ### Install go-isatty Package Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/mattn/go-isatty/README.md Use this command to install the go-isatty package into your Go workspace. ```bash go get github.com/mattn/go-isatty ``` -------------------------------- ### Start-ee.sh Example: Default Behavior Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Runs tests with default settings, including stopping and cleaning up the GitLab container afterward. ```bash ./start-ee.sh ``` -------------------------------- ### Install Ghorg with Golang (Go 1.16+) Source: https://github.com/gabrie30/ghorg/blob/master/README.md Installs ghorg using the 'go install' command for Go versions 1.16 and newer. Ensure your Go bin directory is in your PATH. ```bash # ensure $HOME/go/bin is in your path ($ echo $PATH | grep $HOME/go/bin) # if using go 1.16+ locally go install github.com/gabrie30/ghorg@latest ``` -------------------------------- ### GitLab Configuration YAML Example Source: https://github.com/gabrie30/ghorg/blob/master/vendor/gitlab.com/gitlab-org/api/client-go/README.md Example YAML configuration file for the GitLab API client, demonstrating instance, authentication, and context setup for an OAuth flow. ```yaml version: gitlab.com/config/v1beta1 instances: - name: gitlab-com server: https://gitlab.com auths: - name: oauth-keyring auth-info: oauth2: access-token-source: keyring: service: client-go user: access-token refresh-token-source: keyring: service: client-go user: refresh-token contexts: - name: gitlab-com-keyring instance: gitlab-com auth: oauth-keyring current-context: gitlab-com-keyring ``` -------------------------------- ### Quick Highlight Example Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/alecthomas/chroma/README.md Use the `quick.Highlight` function for simple text formatting without manual configuration. ```go err := quick.Highlight(os.Stdout, someSourceCode, "go", "html", "monokai") ``` -------------------------------- ### Install Ghorg with Golang (Older Versions) Source: https://github.com/gabrie30/ghorg/blob/master/README.md Installs ghorg using the 'go get' command for older Go versions. Ensure your Go bin directory is in your PATH. ```bash # older go versions can run go get github.com/gabrie30/ghorg ``` -------------------------------- ### Start-ee.sh Example: Specific Version and Keep Running Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Runs tests using a specific GitLab Docker image tag and ensures the container remains active post-execution. ```bash ./start-ee.sh false false 16.4.0-ce.0 ``` -------------------------------- ### Setup Reclone Configuration File Source: https://github.com/gabrie30/ghorg/blob/master/README.md Download a sample reclone.yaml configuration file and save it to the default ghorg configuration directory. This provides a template for your own configurations. ```bash curl https://raw.githubusercontent.com/gabrie30/ghorg/master/sample-reclone.yaml > $HOME/.config/ghorg/reclone.yaml ``` -------------------------------- ### Gitea Test Runner Examples Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitea/README.md Examples demonstrating how to use the Gitea test runner to list available tests, run a specific test, or seed with a custom configuration. ```bash # List all available test scenarios ./test-runner/gitea-test-runner -list -token="your-token" # Run specific test ./test-runner/gitea-test-runner -test="all-orgs-basic" -token="your-token" -base-url="http://gitea.example.com:3000" # Seed with custom config ./seeder/gitea-seeder -config="my-seed-data.json" -token="your-token" -base-url="http://gitea.example.com:3000" ``` -------------------------------- ### Install Ghorg using Scoop on Windows Source: https://github.com/gabrie30/ghorg/blob/master/README.md Use this command to add the necessary bucket and install ghorg on Windows via scoop. ```bash scoop bucket add main scoop install ghorg ``` -------------------------------- ### Run Test Suite with Make Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/viper/README.md Execute the project's test suite using the make command. Ensure Go is installed and dependencies are managed. ```shell make test ``` -------------------------------- ### Run Bitbucket Server Integration Tests Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-bitbucket/README.md Executes the full integration test suite for Bitbucket Server. This script starts a local Docker container, pauses for manual setup, and then proceeds with seeding and testing. ```bash ./start.sh ``` -------------------------------- ### Install jsontoml tool Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/pelletier/go-toml/v2/README.md Installs the jsontoml command-line tool. Use this to convert JSON files to TOML. ```bash go install github.com/pelletier/go-toml/v2/cmd/jsontoml@latest jsontoml --help ``` -------------------------------- ### Start-ee.sh Example: Keep GitLab Running Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Executes tests while keeping the GitLab container running after completion, useful for debugging purposes. ```bash ./start-ee.sh false ``` -------------------------------- ### Install tomll tool Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/pelletier/go-toml/v2/README.md Installs the tomll command-line tool. Use this to lint and reformat TOML files. ```bash go install github.com/pelletier/go-toml/v2/cmd/tomll@latest tomll --help ``` -------------------------------- ### Install tomljson tool Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/pelletier/go-toml/v2/README.md Installs the tomljson command-line tool. Use this to convert TOML files to JSON. ```bash go install github.com/pelletier/go-toml/v2/cmd/tomljson@latest tomljson --help ``` -------------------------------- ### Common Start Script Scenarios Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitea/README.md Provides common usage patterns for the `start.sh` script tailored for development, CI/CD, specific version testing, and custom data persistence. ```bash # Development - keep Gitea running for multiple test iterations ./start.sh false false latest # CI/CD - use clean environment and cleanup afterwards (default) ./start.sh true false latest # Testing specific Gitea version ./start.sh true false 1.19.0 # Custom data persistence for repeated testing ./start.sh false true latest /data/gitea-persistent ``` -------------------------------- ### Install Cobra CLI Generator Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/cobra/README.md Install the cobra-cli tool for scaffolding Cobra applications. ```go go install github.com/spf13/cobra-cli@latest ``` -------------------------------- ### Seed Gitea Script Examples Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitea/README.md Demonstrates how to run the `seed.sh` script, showing both default usage and custom parameter overrides. ```bash # Use defaults ./seed.sh # Custom parameters ./seed.sh "my-token" "http://gitea.local:3000" "/tmp/ghorg" ``` -------------------------------- ### Programmatic Test Runner Usage Examples Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitea/README.md Examples for using the Gitea test runner programmatically after building it. Includes commands to list available tests and run a specific test. ```bash # List available tests ./gitea-test-runner -list -token="your-token" # Run a specific test ./gitea-test-runner -test="specific-test-name" -token="your-token" -base-url="http://gitea.example.com:3000" ``` -------------------------------- ### Import GitLab Client Library Source: https://github.com/gabrie30/ghorg/blob/master/vendor/gitlab.com/gitlab-org/api/client-go/README.md Import the necessary package to start using the GitLab API client. ```go import "gitlab.com/gitlab-org/api/client-go" ``` -------------------------------- ### Install conc Package Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/sourcegraph/conc/README.md Use this command to add the conc library to your Go project. ```sh go get github.com/sourcegraph/conc ``` -------------------------------- ### TOML with Comments Example Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/pelletier/go-toml/v2/README.md Demonstrates how go-toml can preserve and generate TOML documents with comments and commented-out values, useful for configuration files. ```toml # Host IP to connect to. host = '127.0.0.1' # Port of the remote server. port = 4242 # Encryption parameters (optional) # [TLS] # cipher = 'AEAD-AES128-GCM-SHA256' # version = 'TLS 1.3' ``` -------------------------------- ### Get Configuration Values Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/viper/README.md Demonstrates how to retrieve configuration values using Viper's Get methods. It highlights case-insensitive retrieval and checking for the existence of a key using IsSet. Zero values are returned if a key is not found or fails to parse. ```go viper.GetString("logfile") // case-insensitive Setting & Getting if viper.GetBool("verbose") { fmt.Println("verbose enabled") } ``` -------------------------------- ### ToString Examples Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/cast/README.md Demonstrates converting various types to strings using cast.ToString. If conversion fails, an empty string is returned. ```go cast.ToString("mayonegg") // "mayonegg" cast.ToString(8) // "8" cast.ToString(8.31) // "8.31" cast.ToString([]byte("one time")) // "one time" cast.ToString(nil) // "" var foo interface{} = "one more time" cast.ToString(foo) // "one more time" ``` -------------------------------- ### Install jwt-go Package Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/golang-jwt/jwt/v4/README.md Use this command to add jwt-go as a dependency in your Go program. ```sh go get -u github.com/golang-jwt/jwt/v4 ``` -------------------------------- ### Get Formatter and Style Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/alecthomas/chroma/README.md Retrieve a style and formatter by their names, with fallbacks if not found. ```go style := styles.Get("swapoff") if style == nil { style = styles.Fallback } formatter := formatters.Get("html") if formatter == nil { formatter = formatters.Fallback } ``` -------------------------------- ### Start-ee.sh Common Scenario: Testing Specific Version Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Demonstrates how to run integration tests against a specific GitLab version by providing the desired image tag. ```bash ./start-ee.sh true false 16.3.0-ce.0 ``` -------------------------------- ### Go Image Resizing Examples Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/disintegration/imaging/README.md Demonstrates various ways to resize images using different methods and filters. Use `Resize` for fixed dimensions, `Fit` to scale within bounds while preserving aspect ratio, and `Fill` to crop and resize to fill a target area. Supports multiple resampling filters like Lanczos, CatmullRom, and Linear. ```go // Resize srcImage to size = 128x128px using the Lanczos filter. dstImage128 := imaging.Resize(srcImage, 128, 128, imaging.Lanczos) // Resize srcImage to width = 800px preserving the aspect ratio. dstImage800 := imaging.Resize(srcImage, 800, 0, imaging.Lanczos) // Scale down srcImage to fit the 800x600px bounding box. dstImageFit := imaging.Fit(srcImage, 800, 600, imaging.Lanczos) // Resize and crop the srcImage to fill the 100x100px area. dstImageFill := imaging.Fill(srcImage, 100, 100, imaging.Center, imaging.Lanczos) ``` -------------------------------- ### Install Ghorg with Homebrew Source: https://github.com/gabrie30/ghorg/blob/master/README.md Installs the ghorg tool using the Homebrew package manager. ```bash brew install ghorg ``` -------------------------------- ### Create and Configure Ghorg Source: https://github.com/gabrie30/ghorg/blob/master/README.md This snippet shows how to create the ghorg configuration directory, download a sample configuration file, and open it for editing. ```bash mkdir -p $HOME/.config/ghorg curl https://raw.githubusercontent.com/gabrie30/ghorg/master/sample-conf.yaml > $HOME/.config/ghorg/conf.yaml vi $HOME/.config/ghorg/conf.yaml # To update your configuration ``` -------------------------------- ### Install Ghorg with Mise Source: https://github.com/gabrie30/ghorg/blob/master/README.md Installs the latest version of ghorg globally using the Mise version manager. ```bash mise use -g ghorg@latest ``` -------------------------------- ### Start-ee.sh Common Scenario: CI/CD Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Sets up the test environment for CI/CD pipelines, utilizing a clean environment and ensuring cleanup after tests complete, mirroring the default behavior. ```bash ./start-ee.sh true false latest ``` -------------------------------- ### Create and Use GitLab Client with Configuration Source: https://github.com/gabrie30/ghorg/blob/master/vendor/gitlab.com/gitlab-org/api/client-go/README.md Go code snippet demonstrating how to create a GitLab API client using the experimental configuration package, load settings from a YAML file, and make an API call. ```go package main import ( "fmt" "log" "gitlab.com/gitlab-org/api/client-go" "gitlab.com/gitlab-org/api/client-go/config" ) func main() { // Create a config with default location (~/.config/gitlab/config.yaml) cfg := config.New( config.WithOAuth2Settings(config.OAuth2Settings{ AuthorizationFlowEnabled: true, CallbackServerListenAddr: ":7171", Browser: func(url string) error { fmt.Printf("Open: %s\n", url) return nil }, ClientID: "", RedirectURL: "http://localhost:7171/auth/redirect", Scopes: []string{"read_api"}, }), ) // Load the configuration if err := cfg.Load(); err != nil { log.Printf("Failed to load config: %v", err) return } client, err := cfg.NewClient(gitlab.WithUserAgent("my-app")) if err != nil { log.Fatalf("Failed to create client: %v", err) } // Use the client user, _, err := client.Users.CurrentUser() if err != nil { log.Fatalf("Failed to get current user: %v", err) } fmt.Printf("Authenticated as: %s (%s)\n", user.Name, user.Username) } ``` -------------------------------- ### Initialize MinIO Backend Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/afero/README.md Instantiate an Afero filesystem for MinIO object storage. This backend provides S3-compatible storage with deduplication and optimization features. ```go import "github.com/cpyun/afero-minio" minioFs := miniofs.NewMinioFs(ctx, "minio://endpoint/bucket") ``` -------------------------------- ### Start-ee.sh Common Scenario: Development Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Configures the test environment for development by keeping GitLab running across multiple test iterations and persisting its data. ```bash ./start-ee.sh false false latest ``` -------------------------------- ### Register and Use Aliases for Keys Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/viper/README.md Demonstrates how to register aliases for configuration keys, allowing a single value to be referenced by multiple names. ```go viper.RegisterAlias("loud", "Verbose") vper.Set("verbose", true) // same result as next line vper.Set("loud", true) // same result as prior line vper.GetBool("loud") // true vper.GetBool("verbose") // true ``` -------------------------------- ### Start Reclone Server Source: https://github.com/gabrie30/ghorg/blob/master/cmd/examples-copy/reclone-server.md Starts the ghorg reclone server. It defaults to port 8080, but a custom port can be specified using the --port flag. ```sh ghorg reclone-server ``` -------------------------------- ### Basic GET Request with go-retryablehttp Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/hashicorp/go-retryablehttp/README.md Demonstrates the simplest usage of the library for making a GET request. The call blocks and retries with exponential backoff if the request fails. ```go resp, err := retryablehttp.Get("/foo") if err != nil { panic(err) } ``` -------------------------------- ### Install and Convert CSV to JSON Source: https://github.com/gabrie30/ghorg/blob/master/README.md Installs the csvToJson utility and converts the ghorg stats CSV file to JSON format. Ensure ghorg stats are enabled to generate the CSV. ```bash go install github.com/gabrie30/csvToJson@latest && \ csvToJson _ghorg_stats.csv ``` -------------------------------- ### Start-ee.sh Script Arguments Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Defines the usage pattern for the start-ee.sh script, detailing its 7 optional arguments, their defaults, and descriptions. This script is the main entry point for running the entire test suite. ```bash ./start-ee.sh [STOP_GITLAB_WHEN_FINISHED] [PERSIST_GITLAB_LOCALLY] [GITLAB_IMAGE_TAG] [GITLAB_HOME] [GITLAB_HOST] [GITLAB_URL] [LOCAL_GITLAB_GHORG_DIR] ``` -------------------------------- ### Start GitLab Docker Container Script Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Starts the GitLab Docker container. This script is called internally by `start-ee.sh` and accepts GitLab image tag, home directory, host, and persistence settings. ```bash ./run-ee.sh [GITLAB_IMAGE_TAG] [GITLAB_HOME] [GITLAB_HOST] [PERSIST_GITLAB_LOCALLY] ``` -------------------------------- ### Initialize Amazon S3 Backend Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/afero/README.md Create a new Afero filesystem backed by Amazon S3. This backend is production-ready and built on the official AWS SDK for Go. ```go import "github.com/fclairamb/afero-s3" s3fs := s3.NewFs(bucket, session) ``` -------------------------------- ### Import jwt-go Package Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/golang-jwt/jwt/v4/README.md Import the jwt package into your Go code to start using its functionalities. ```go import "github.com/golang-jwt/jwt/v4" ``` -------------------------------- ### Definition List Syntax Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/gomarkdown/markdown/README.md Example of a definition list in Markdown, with terms followed by a colon and their definitions. ```markdown Cat : Fluffy animal everyone likes Internet : Vector of transmission for pictures of cats ``` -------------------------------- ### Start-ee.sh Common Scenario: Custom Data Persistence Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Configures the test environment to use custom data persistence settings, allowing for repeated testing with retained GitLab data. ```bash ./start-ee.sh false true latest /data/gitlab-persistent ``` -------------------------------- ### Basic fsnotify Watcher Usage in Go Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/fsnotify/fsnotify/README.md Demonstrates how to create a new watcher, listen for events and errors in a goroutine, add a directory to watch, and handle potential errors. Ensure the event and error channels are processed to avoid blocking. ```go package main import ( "log" "github.com/fsnotify/fsnotify" ) func main() { // Create new watcher. watcher, err := fsnotify.NewWatcher() if err != nil { log.Fatal(err) } defer watcher.Close() // Start listening for events. go func() { for { select { case event, ok := <-watcher.Events: if !ok { return } log.Println("event:", event) if event.Has(fsnotify.Write) { log.Println("modified file:", event.Name) } case err, ok := <-watcher.Errors: if !ok { return } log.Println("error:", err) } } }() // Add a path. err = watcher.Add("/tmp") if err != nil { log.Fatal(err) } // Block main goroutine forever. <-make(chan struct{}) } ``` -------------------------------- ### Identify Language by Syntax ID Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/alecthomas/chroma/README.md Get a lexer for a specific language using its Chroma syntax ID. ```go lexer := lexers.Get("go") ``` -------------------------------- ### Building Cloud-Agnostic Applications with Afero Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/afero/README.md Design applications to work seamlessly with various storage backends by injecting an `afero.Fs` interface. This example demonstrates a document processing service. ```go type DocumentProcessor struct { fs afero.Fs } func NewDocumentProcessor(fs afero.Fs) *DocumentProcessor { return &DocumentProcessor{fs: fs} } func (p *DocumentProcessor) Process(inputPath, outputPath string) error { // This code works whether fs is local disk, cloud storage, or memory content, err := afero.ReadFile(p.fs, inputPath) if err != nil { return err } processed := processContent(content) return afero.WriteFile(p.fs, outputPath, processed, 0644) } // Use with local filesystem processor := NewDocumentProcessor(afero.NewOsFs()) // Use with Google Cloud Storage processor := NewDocumentProcessor(gcsFS) // Use with in-memory filesystem for testing processor := NewDocumentProcessor(afero.NewMemMapFs()) ``` -------------------------------- ### Create Repository Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/ktrysmt/go-bitbucket/README.md Shows how to create a new repository using the go-bitbucket client, specifying repository details. ```APIDOC ## Create Repository ### Description Creates a new repository in Bitbucket. ### Method `Repositories.Repository.Create` ### Parameters - `opt` (*bitbucket.RepositoryOptions) - Required - Options for creating the repository. - `Owner` (string) - Required - The owner of the repository. - `RepoSlug` (string) - Required - The slug of the repository. - `Scm` (string) - Required - The SCM type (e.g., "git"). ### Request Example ```go opt := &bitbucket.RepositoryOptions{ Owner: "project_name", RepoSlug: "repo_name", Scm: "git", } res, err := c.Repositories.Repository.Create(opt) ``` ### Response #### Success Response (200) Returns the created repository object. #### Response Example (Response structure depends on the Bitbucket API, not detailed in source) ``` -------------------------------- ### Final String Output Example Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/briandowns/spinner/README.md Displays the expected output when the `FinalMSG` is configured and the spinner completes its operation. ```Text Complete! New line! Another one! ``` -------------------------------- ### Write Current Configuration to File Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/viper/README.md Provides examples for writing the current Viper configuration to a file. Includes options for overwriting existing files or safely writing only if the file does not exist. ```go viper.WriteConfig() // writes current config to predefined path set by 'viper.AddConfigPath()' and 'viper.SetConfigName' vper.SafeWriteConfig() vper.WriteConfigAs("/path/to/my/.config") vper.SafeWriteConfigAs("/path/to/my/.config") // will error since it has already been written vper.SafeWriteConfigAs("/path/to/my/.other_config") ``` -------------------------------- ### Lexer Conversion Script Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/alecthomas/chroma/README.md Example of using the `pygments2chroma.py` script to convert a Pygments lexer to Chroma format. ```sh python3 _tools/pygments2chroma.py \ pygments.lexers.jvm.KotlinLexer \ > lexers/k/kotlin.go \ && gofmt -s -w lexers/k/kotlin.go ``` -------------------------------- ### Create a Repository with Go Bitbucket Client Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/ktrysmt/go-bitbucket/README.md This Go code demonstrates how to create a new repository in Bitbucket using the API token authentication. You need to provide the owner, repository slug, and the desired SCM type (e.g., "git"). ```go package main import ( "fmt" "github.com/ktrysmt/go-bitbucket" ) func main() { c := bitbucket.NewAPITokenAuth("you@example.com", "your-api-token") opt := &bitbucket.RepositoryOptions{ Owner: "project_name", RepoSlug: "repo_name", Scm: "git", } res, err := c.Repositories.Repository.Create(opt) if err != nil { panic(err) } fmt.Println(res) } ``` -------------------------------- ### Fenced Code Block with Language Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/gomarkdown/markdown/README.md Example of a fenced code block in Go, specifying the language for syntax highlighting. ```go ```go func getTrue() bool { return true } ``` ``` -------------------------------- ### Get Spinner Status Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/briandowns/spinner/README.md Demonstrates how to check if the spinner is currently active or running. This can be used for conditional logic or status reporting. ```Go fmt.Println(s.Active()) ``` -------------------------------- ### Get Reclone Statistics Source: https://github.com/gabrie30/ghorg/blob/master/examples/reclone-server.md Returns the statistics of the reclone operations in JSON format. Requires GHORG_STATS_ENABLED=true or --stats-enabled to be set. ```APIDOC ## GET /stats ### Description Returns the statistics of the reclone operations in JSON format. `GHORG_STATS_ENABLED=true` or `--stats-enabled` must be set to work. ### Method GET ### Endpoint /stats ### Responses #### Success Response (200 OK) Statistics returned successfully. #### Error Response (428 Precondition required) Ghorg stats is not enabled. #### Error Response (500 Internal Server Error) Unable to read the statistics file. ``` -------------------------------- ### Download Go Modules Source: https://github.com/gabrie30/ghorg/blob/master/scripts/local-gitlab/README.md Ensure all necessary Go modules are downloaded for the seeder and test-runner components before building or running. ```bash cd seeder && go mod download cd test-runner && go mod download ``` -------------------------------- ### Import go-colorful Package Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/lucasb-eyer/go-colorful/README.md Import the go-colorful package into your Go source files to start using its color manipulation functionalities. ```go import "github.com/lucasb-eyer/go-colorful" ``` -------------------------------- ### Testing Filesystem Operations with MemMapFs Source: https://github.com/gabrie30/ghorg/blob/master/vendor/github.com/spf13/afero/README.md Demonstrates how to use afero.NewMemMapFs() for in-memory filesystem testing. This provides a fast, reliable, and isolated environment for testing filesystem-dependent code without disk I/O. ```go func SaveUserData(fs afero.Fs, userID string, data []byte) error { filename := fmt.Sprintf("users/%s.json", userID) return afero.WriteFile(fs, filename, data, 0644) } func TestSaveUserData(t *testing.T) { // Create a clean, fast, in-memory filesystem for testing testFS := afero.NewMemMapFs() userData := []byte(`{"name": "John", "email": "john@example.com"}`) err := SaveUserData(testFS, "123", userData) if err != nil { t.Fatalf("SaveUserData failed: %v", err) } // Verify the file was saved correctly saved, err := afero.ReadFile(testFS, "users/123.json") if err != nil { t.Fatalf("Failed to read saved file: %v", err) } if string(saved) != string(userData) { t.Errorf("Data mismatch: got %s, want %s", saved, userData) } } ``` -------------------------------- ### Struct Field Ordering Example Source: https://github.com/gabrie30/ghorg/blob/master/vendor/gitlab.com/gitlab-org/api/client-go/AGENTS.md Struct fields should be ordered to match the GitLab API documentation, including `url` and `json` tags. ```go type CreateProjectOptions struct { Name *string `url:"name,omitempty" json:"name,omitempty"` Description *string `url:"description,omitempty" json:"description,omitempty"` Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"` // ... other fields in API documentation order } ```