Code Monkey home page Code Monkey logo

karn's Introduction

Build Status

karn: Manage multiple Git identities with ease

Setup your Git repositories to always use a specific identity based on the directory tree.

With karn, you never have to manually change the local repository configuration to a different identity from your global.

karn will change your repository's local user.name and user.email configuration if necessary, but will never modify your global configuration.

Install

Homebrew (OS X)

Install using Homebrew on OS X

brew install karn

Pre-built binary

Head to the releases page to download pre-built binaries for OS X/Linux/Windows.

Go

You can install karn using Go with the following command:

go get github.com/prydonius/karn/cmd/karn

Arch Linux

karn has a AUR package: https://aur.archlinux.org/packages/karn/. You can install it using your AUR helper of choice.

Usage

karn can be used in two ways!

Automatically check for identity updates before running a Git command

Note: this method overrides the git command with a function that runs karn update before executing the original Git command. Run karn init to see exactly what the git command is overriden with

If you're okay with the scary warnings above, add the following line to your shell startup script (e.g. .bash_profile, .zshrc)

if which karn > /dev/null; then eval "$(karn init)"; fi

If you run on fish you can put this line in your config.fish

alias git="karn update; command git $argv"

Run manually when you want to update

Alternatively, you can run karn update manually in a Git repository whenever you need to update your identity for that repository.

Configuring Identities

karn looks for a YAML configuration file in your home directory, ~/.karn.yml.

A sample configuration looks like this:

---
~/Fun:
  name: Adnan Abdulhussein
  email: [email protected]
~/Fun/karn:
  name: Sisterhood of Karn
  email: [email protected]
/Work:
  name: Adnan A
  email: [email protected]
  signingKey: 3AA5C34371567BD2

In a given repo, karn will try to match with the deepest configured directory. For the configuration above, any repo under the ~/Fun directory will match the first identity, with the exception of ~/Fun/karn which matches the second identity. If an identity isn't found, the repo is left untouched.

karn's People

Contributors

prydonius avatar sschuberth avatar captn3m0 avatar danielmschmidt avatar chenrui333 avatar mkmik avatar

Stargazers

advaith avatar Abhinav Sharma avatar Eddie Hillenbrand avatar Vikram Singh Panwar avatar William Good avatar Pascal Küsgen avatar Kaapeine avatar Supriyo Sarkar avatar Haig Nalbandian avatar  avatar Daniel Bubenheim avatar  avatar  avatar ayush gupta avatar Sondre Gjellestad avatar Ashutosh Gangwar avatar tacotexmex avatar Boom avatar REGE avatar chhe avatar Salmanul Farzy avatar JLA avatar  avatar Umang Galaiya avatar Daniel Banck avatar Petar Grgic avatar  avatar Lúcio Caetano avatar Andrii Oriekhov avatar Andreas Partsch avatar Markus Wolf avatar ◤◢◤◢◤◢◤◢ avatar Nikolas Evers avatar David Authier avatar Maple avatar  avatar Stephan Deumier avatar  avatar Max Liashuk avatar 90DY avatar Nicholas Morera avatar 仿生狮子 avatar Robert K. Pauls avatar stagas avatar alv avatar Seongyong Choi avatar Sunny avatar Matej avatar Jay Parmani avatar sen ✦ avatar Otis Sutton avatar Ram Damera avatar Laxman avatar Adrian Cando avatar Ya Zhuang avatar Toan Tran avatar Eva1ent avatar Moni avatar Joker_ avatar Kaleo avatar odanado avatar Anonimus Programus avatar  avatar Casey Kuhlman avatar Enrique Benitez avatar Socheat Sok avatar MOCHIZUKI Natsune avatar Sora Morimoto avatar Khoa Nguyen avatar Ross Bratton avatar Samuel avatar fall simply avatar Veit Lehmann avatar Daniel Perez Alvarez avatar Software Engineer avatar Dario Vladović avatar Giovanni Delgado avatar David avatar EGOIST avatar Matan Kushner avatar Prateek Sharma avatar YCM Jason avatar Huang Shuo-Han avatar khimaros avatar Doğan Çelik avatar Philipp Defner avatar wolfi3 avatar Julien K avatar Gonçalo Mendes Cabrita avatar Daniel Serrano avatar tg-z avatar  avatar Doru Carastan avatar Tamarakuro Patrick Foh Jr avatar Robert Muller avatar 10sr avatar Akira Komamura avatar t3nzin avatar Scott Ivey avatar Michael Joseph avatar

Watchers

Christopher de Beer avatar James Cloos avatar Sandeep Sangamreddi avatar Codedaiquiri avatar  avatar Manu avatar Yancy avatar Ralph avatar  avatar

karn's Issues

how do you run it?

Hi, Sorry for the stupid question. But how does one run this? I have not worked with go applications much and not at all on this machine so I installed golang from synaptic; I don't know if it's like python or ruby where you have to massage the environment sometimes; maybe I am just missing a component.

Below is what I did if it's of any interest (may not be) but what I am really hoping for is to learn:

  1. what are the dependencies, environment requirements etc? I have go version go1.10.4 linux/amd64; is it sufficient?
  2. how are you supposed to invoke it? presumably something needs to get put on the path..? I'm missing the step.

Any hints appreciated! :) Thank you for making and sharing a program to deal with this very tenacious problem in git.


Anyway first I tried installing via Go:

$ go get github.com/prydonius/karn/cmd/karn

# github.com/prydonius/karn/cmd/karn
go/src/github.com/prydonius/karn/cmd/karn/karn.go:16:5: app.Author undefined (type *cli.App has no field or method Author)
go/src/github.com/prydonius/karn/cmd/karn/karn.go:17:5: app.Email undefined (type *cli.App has no field or method Email)
go/src/github.com/prydonius/karn/cmd/karn/karn.go:19:15: cannot use commands() (type []cli.Command) as type []*cli.Command in assignment
go/src/github.com/prydonius/karn/cmd/karn/karn.go:28:10: cannot use func literal (type func(*cli.Context)) as type cli.ActionFunc in field value
go/src/github.com/prydonius/karn/cmd/karn/karn.go:35:10: cannot use func literal (type func(*cli.Context)) as type cli.ActionFunc in field value
go/src/github.com/prydonius/karn/cmd/karn/karn.go:42:10: cannot use func literal (type func(*cli.Context)) as type cli.ActionFunc in field value

so I downloaded the binary but not sure what to do with any of these files. looked online for how to run golang programs and this was suggested:

$ go run karn.go
go run: cannot run non-main package

Looked into that error code and couldn't find anything that made sense.

Tried running it like anything else,

$ ./karn.go 
zsh: permission denied: ./karn.go

so gave some permissions:

$ chmod +x karn.go 
./karn.go       
./karn.go: package: not found
./karn.go: Syntax error: newline unexpected (expecting ")")

And I gave up. :)

Fish shell support

I use Fish. I like Karn. Currently, I have a Fish function that takes the place of karn's init and it works. I can put together the code if you're open to a PR.

"Couldn't retrieve identity from Git repository." if no global signing key is set.

repo.go in #25 (implement gpg signing) added a getconfig for a signingkey (see repo.go diff). This causes a "Couldn't retrieve identity from Git repository" issue if a user hasn't setup a signingkey at all in their global ~/.gitconfig.

Suggest making this a soft-check, possibly not just for signingkey but for all global gitconfig identity attributes if the intent of karn is to not depend on any global identity aspects.

Workaround for now is to set a global signing key in ~/.gitconfig before using karn.

Add quiet flag

Running git init (or any git commands) with karn overriding git outputs "Not inside Git work tree". When karn is overriding it should be more quiet.

Add to Homebrew?

Not much more to add, just wondering if you can add this so it can be installed via brew install karn.

Should karn unset local identity if it's missing?

At the moment, if a repo doesn't have a matching configuration, karn won't touch the local configuration. Should karn unset the local configuration so that in these cases the default/global identity is always used?

e.g.

  1. Set identity in karn.yml
/repo:
  name: Adnan A
  1. Run
    $ karn update
  2. Remove identity in karn.yml
  3. Run
    $ karn update

Name is kept as "Adnan A" and not reset back to global/default.

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.