Coder Social home page Coder Social logo

prashamtrivedi / gitconfig-provider Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 101 KB

Cli Utility to add configurations according to git remotes

Home Page: https://prashamhtrivedi.in/gitconfig-provider.html

License: Apache License 2.0

Go 95.62% Dockerfile 4.38%
golang cobra git-config devcontainer vscode

gitconfig-provider's Introduction

CLI Utility to add configurations as per git remote.

This is a CLI Utility which stores configurations according to git remotes. And applies your configurations according to current remotes. This commands automatically detects github, bitbucket and gitlab and applies properties in the repository.

How to use

Download CLI according to your platform. And run

All options

gitconfig-provider --help

This will list all available commands.

Main commands to note

These are list of commands along with their use cases. To know the inputs and other details about commands please run gitconfig-provider [command] --help.

  • listProviders: Lists all providers along with properties we have added using this CLI,

  • addProvider: Adds new provider with empty properties

  • addConfig: Adds properties as key value pair to given git provider.

  • deleteConfig: Deletes property from given git provider.

  • reset: Reset all git providers and properties to the original state.

  • apply: Detects remote from current git repository, for remote detection it prefers origin as remote name, if no origin found, it prefers first remote from git remote -v command, and applies configuration according to detected remote.

Test locally or on your broswer.

Open in Visual Studio Code

Open In github.dev

gitconfig-provider's People

Contributors

prashamtrivedi avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gitconfig-provider's Issues

Backup the settings in cloud and load the settings from cloud

Backup settings from cloud.

Accept a url when we can write a JSON file. If a url is unreachable or not writable throw an error and don't copy anything.

Proposed commands with flags

  • backup : Will backup data, save (override if already there) current config json to url.
    Flags:
    - url or u: (Required) Url to write the backup file to.
    - header or h: (Optional) Header key-value pair if required to write to.
  • restore : Will read latest data from url and apply it to current config
    Flags:
    - url or u: (Required) Url to write the backup file to.
    - header or h: (Optional) Header key-value pair if required to read from.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

dockerfile
.devcontainer/Dockerfile
  • mcr.microsoft.com/vscode/devcontainers/go 0-1.18
.gitpod.Dockerfile
  • gitpod/workspace-full 2022-05-17-12-26-08
github-actions
.github/workflows/add-to-planner.yml
  • actions/github-script v7
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-go v5
  • goreleaser/goreleaser-action v5
gomod
go.mod
  • go 1.19
  • github.com/mitchellh/go-homedir v1.1.0
  • github.com/spf13/cobra v1.8.0

  • Check this box to trigger a request for Renovate to run again on this repository

Provider with Suffix isn't recognised as separate provider.

We already have 3 providers. Github, Bitbucket and Gitlab

If I try to add a provider with "github.com/something/" it is not recognised as separate provider but considers it as "github".

I have added Two failing test cases to demonstrate that

  • Case 1
    provider, index = GetProviderByUrl("https://github.com/myoffice/")
    if index != -1 {
    t.Errorf("Expected index to be -1, but got %v", index)
    }
    if provider.Name != "" {
    t.Errorf("Expected provider to be nil, but got %v", provider)
    }
  • Case 2
    func TestApply(t *testing.T) {
    failingScenario := []GitProvider{
    {
    Name: "Github", Url: "https://github.com/",
    },
    {
    Name: "GithubOffice", Url: "https://github.com/office/",
    },
    }
    writeGitProviders(failingScenario)
    provider, index := GetProviderByUrl("https://github.com/PrashamTrivedi/gitconfig-provider.git")
    if index == -1 {
    t.Errorf("Provider must be found")
    }
    if strings.ToLower(provider.Name) != "github" {
    t.Errorf("Provider Name should be github but got %s", provider.Name)
    }
    provider, index = GetProviderByUrl("https://github.com/office/my-repo.git")
    if index == -1 {
    t.Errorf("Provider must be found")
    }
    if strings.ToLower(provider.Name) != "githuboffice" {
    t.Errorf("Provider Name should be GithubOffice but got %s", provider.Name)
    }
    ResetProviders()
    }

The failing code is here

if strings.HasPrefix(providerUrl, provider.Url) {
providerToReturn = provider
indexToReturn = index
break
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.