Giter Site home page Giter Site logo

luiserebii / git-identity Goto Github PK

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

:trident: A command line tool allowing for easy shifting between git identities (username, email, and GPG).

License: MIT License

JavaScript 2.36% Shell 5.45% TypeScript 92.19%

git-identity's People

Contributors

dependabot[bot] avatar luiserebii avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

git-identity's Issues

Tests only test Identity class and I/O, but not git functionality

The tests, at the moment, test for the following:

  • Expected results from class Identity functions
  • Addition/edit/update/removal of identities from/to file

However, things such as getting or setting identities aren't. As git is a tool that exists on a "global scope", tests are required to test on an isolated instance of git. I'm not 100% sure how this is accomplished, which is why this piece, unfortunately, must be tested manually, which is technically a bit of a risk to do on personal setups.

The following functions:
shiftIdentity()
shiftIdentityLocal()
getIdentityGlobal()
getIdentityLocal()
setIdentityGlobal()
setIdentityLocal()
are thus untested.

If anyone knows how to accomplish this, kindly post below, or make a PR ๐Ÿ˜ƒ

Adding a `git-identity clone` command to avoid accidental commits

Often, a user might quickly clone a certain repo and want to make a minor commit and push; doing this can often result in the user forgetting to switch identities, end up making some sort of mistaken push, and, go through the effort of correcting it and force-pushing, which is bad practice.

I suggest the following syntax:

git-identity clone -i [id-name] [repo-link]

In order to keep complete compatibility with git clone, we will also need to pass down all the flags git clone can take. Since -s is already reserved, we will need to use a different flag; I think -i | --id can work great, which is essentially a functional alias of -s | --set.

Adding a method to revise previous commit history

The ability to rewrite previous authors is not a rare need, and being able to do this easily within the tool would improve its utility. This shouldn't be too difficult to implement, as the bash script to do this is already written:

#!/bin/sh

git filter-branch --env-filter '

OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

courtesy of GitHub: https://help.github.com/en/articles/changing-author-info

This does not include, however, times where the emails might match with two different identities/GPG keys, at which point, it would be needed to check names and GPG keys (if possible) as well.

There should be two ways to do this, one agnostic, one not. For example, if a user might want to target a git-identity added and switch to a git-identity also recorded, it could look something like:

git-identity revise --from [IDToChange] --to [IDToChange]

Agnostic:

git-identity revise --from-name [name] --from-email [email] --to-name [name] --to-email [email]

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.