Giter Site home page Giter Site logo

rkotze / git-mob Goto Github PK

View Code? Open in Web Editor NEW
178.0 7.0 22.0 2.18 MB

Co-author commits tool. A cross-platform command-line tool for social coding. Includes co-authors in commits when pair/mob programming.

Home Page: https://www.npmjs.com/package/git-mob

License: MIT License

JavaScript 28.03% TypeScript 71.97%
mob git-mob pair xp github pair-programming mob-programming extreme-programming co-authors git

git-mob's Introduction

Git Mob - Co-author commits

Add co-authors to commits when you collaborate on code. Use when pairing with a team mate or mobbing with your team.

✨ Git Mob VS Code extension

gif showing example usage of git-mob

Git Mob repository is organised into workspaces

🌟 Git Mob CLI documentation: Main npm package to install & see list of features

🌟 Git Mob core documentation: An npm package containing core Git Mob functions

More info

See contribution guidelines

See git-mob discussions

Read our blog post to find out why git-mob exists: Co-author commits with Git Mob

* If you have git-duet installed, you'll need to uninstall it since it conflicts with the git-solo command.

git-mob's People

Contributors

abelazo avatar cjlarose avatar dependabot[bot] avatar dideler avatar dsernst avatar ipwright83 avatar jackbittiner avatar joelash avatar jonsmithers avatar mocoso avatar nickautomatic avatar punitlad avatar richardkotze-tl avatar rkotze avatar sarabadu avatar sultanhq avatar tlabeeuw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-mob's Issues

Avoid shell calls for interacting with git

Right now we're wrapping the git binary in child process calls that are executed in their own shell instance. That's not very efficient.

Consider using libgit bindings or an ini file parser (could be one specific to git config, e.g. https://github.com/jonschlinkert/parse-git-config or https://github.com/eugeneware/git-config).

Note that the parsers will be read-only, so if we use those, there may have to be a compromise where we only use it for reads and continue to use a shell for writes. We could write to the file without going through git, but then we don't get any of the protection that git provides (e.g. helps prevent you from setting illegal config).

GitMob handleResponse: "git config --get --global commit.template"

Prerequisites

Description

If commit.template is not set on git, The GitMob handleResponse: "git config --get --global commit.template" file is being created when ran the command.

return `GitMob handleResponse: "${query}" ${response.stderr.trim()}`;

Steps to Reproduce

  1. make sure commit.template has not been set
  2. run command normally

Expected behavior: [What you expect to happen]
Throw the error and abort operation, without creating the new file
Actual behavior: [What actually happens]
creates unfriendly file
Reproduces how often: [What percentage of the time does it reproduce?]
everytime ran command

Versions

  • operating system and version: Ubutnu 23.04
  • git-mob version (git-mob --version): via latest vscode extension
  • git version (git --version):git version 2.40.1

Additional Information

No .gitmessage file found to write to

image

  • Git mob 0.2.2
  • Git 2.10.1.windows.1
  • Window 10
  • Node 8.11.1

Description

Changing author throws a error saying no such file or directory open and the .gitmessage file is not updated

Steps to Reproduce

  1. Command git mob [author]
  2. Unhandled error
  3. Co-authors not updated

Expected behavior: .gitmessage file to be updated with co-authors

Actual behavior: .gitmessage file not updated with co-authors

Reproduces how often: 100% of the time

Include filter for suggest-coauthors command

Summary

Some git repositories have lots of contributors and would be good to filter the list down to make it easier to find that co-author's details.

Motivation

Better experience adding new co-authors.

Additional context

The filtering should be case-insensitive.

$ git suggest-coauthors <author name | author email>

Add CI server

So we can automatically run tests when using pull requests.
Show on the README when the build is passing/failing by using a badge.
Consider using Travis or CircleCI.

Show co-authors when making a commit

Summary

Prints added co-authors to the terminal when making commits.

Here's what it looks like (name & email hidden for their privacy):
image

(gacm is an alias for git commit add .; git commit -m)

Motivation

I wanted to be reminded whenever making commits that co-authors were also being added.

Describe alternatives you've considered

editing PS1

Additional context

Here, I got this working already in my modified git hook:

#!/usr/bin/env node
const { exec } = require('child_process')
const { readFileSync, writeFileSync } = require('fs')

const commitMessage = process.argv[2]

// expect .git/COMMIT_EDITMSG
if (/COMMIT_EDITMSG/g.test(commitMessage)) {
  let contents = ""

  // Grab the current co-author settings
  exec("git mob-print", (err, coAuthors) => {
    if (err) return process.exit(0)

    // Grab the current commit message
    contents = readFileSync(commitMessage)

    // Skip if the commit message already contains current co-author settings
    if (contents.includes(coAuthors.trim())) return process.exit(0)

+    // Show console that we're adding co-authors
+    const cyan = '\x1b[36m%s\x1b[0m'
+    if (coAuthors.trim().length) console.log(cyan, coAuthors.trim())

    const commentPos = contents.indexOf('# ')
    const gitMessage = contents.slice(0, commentPos)
    const gitComments = contents.slice(commentPos)

    // Add co-authors after commit message,
    // before the rest of the comments
    writeFileSync(commitMessage, gitMessage + coAuthors + gitComments)

    // All done
    process.exit(0)
  })
}

Allow per repo `<repo>/.git-coauthors` file

Summary

Instead of only having a global ~/.git-coauthors file, I would like to have a per repo one that can be maintained by the entire team and checked in.

Motivation

This allows us consistancy in maintaining the authors file, and all the advantages of it being tracked by git (history, blame, etc).

Describe alternatives you've considered

Using the env variable GITMOB_COAUTHORS_PATH doesn't work as we work with many repos which belong to different teams.

Additional context

I am willing to submit a PR if that would help. Its an easy enough change. Something to the following file https://github.com/rkotze/git-mob/blob/master/packages/git-mob-core/src/git-mob-api/git-authors/index.js#L107-L111 like:

const { silentRun } = require('../silent-run');

function pathToCoAuthors() {
  if (process.env.GITMOB_COAUTHORS_PATH) {
    return process.env.GITMOB_COAUTHORS_PATH;
  }

  const gitCoAuthorsFilename = process.env.fetch("GITMOB_COAUTHORS_FILENAME", ".git-coauthors");
  const repoAuthorsFile = path.join(gitRootDir(), gitCoAuthorsFilename);

  return fs.existsSync(repoAuthorsFile)
    ? repoAuthorsFile
    : path.join(os.homedir(), gitCoAuthorsFilename);
}

function gitRootDir(gitCoAuthorsFilename) {
  const response = silentRun("git rev-parse --show-toplevel");
  return response.stdout.trim();
}

"git mob --installTemplate" should be optional

Summary

I don't see the point in git-mob requiring there to be a commit template if there is already a prepare-commit-msg hook in place.

Motivation

To remove unnecessary configuration step for users.

Describe alternatives you've considered

Additional context

git mob-print prints a very confusing/unhelpful error when the commit template is missing. This happens when you have the prepare-commit-msg hook installed, but haven't run git mob --installTemplate.

CI Improvement for suggested co-authors

Context

Suggest-coauthors command lists the local contributors to the git repo. When testing in the CI it's important to check out the whole repository over just a single commit because a single commit will only contain one contributor. The tests check for an old contributor and so this will cause a failure. See here this publish failure.

Current mitigation

I've moved the minified test into the main CI to catch the issues earlier. However to have more control over the test data/environment a different solution might be helpful.

Suggested solution

Extend the temporarily created repo for testing to include commits with different authors. Then test one of them shows when running the suggest coauthors command.

git mob and git mob-print commands are not found

Prerequisites

Description

I followed the instructions in the README, but when I try to execute git mob or git mob-print, I receive this response:

git: 'mob-print' is not a git command. See 'git --help'.

Steps to Reproduce

See description

Expected behavior: For these git commands to work after installing this library

Actual behavior: The git commands provided by this library do not work

Reproduces how often: 100%

Versions

  • operating system and version: macOS 11.5.2
  • git-mob version (git-mob --version): 2.0.0
  • git version (git --version): 2.32.0

Additional Information

The readme instructions on using precommit throws an error

Prerequisites

Description

  • Following the readme instructions to use precommit and git-mob together throws an error

The example posted in the read me

// .pre-commit-config.yaml
repos:
  - repo: https://github.com/rkotze/git-mob
    rev: { tag-version }
    hooks:
      - id: add-coauthors
        stages: ["prepare-commit-msg"]

Output: Throws the CLI error - because use of tag-version is not compatible

An error has occurred: InvalidConfigError:
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='https://github.com/rkotze/git-mob')
==> At key: rev
=====> Expected string got dict
Check the log at /Users/timrooke/.cache/pre-commit/pre-commit.log

If I solve this issue by pinning the version:

// .pre-commit-config.yaml
repos:
  - repo: https://github.com/rkotze/git-mob
    rev: v2.3.5
    hooks:
      - id: add-coauthors
        stages: ["prepare-commit-msg"]

Output: Throws the CLI error - because .pre-commit-hooks.yaml is not at the root level of the git-mob report

An error has occurred: InvalidManifestError:
=====> /Users/me/.cache/pre-commit/repoycrmzqj6/.pre-commit-hooks.yaml is not a file
Check the log at /Users/me/.cache/pre-commit/pre-commit.log

Steps to Reproduce

  1. brew install pre-commit
  2. Add a .pre-commit-config.yaml with one of the above configurations
  3. Run pre-commit autoupdate (you may see the error in the CLI at this point)
  4. git add . && git commit -m "Add some files"
  5. The pre-commit hook errors as above

Expected behavior: [What you expect to happen]

  • Pre-commit hook to pass and append any git-mob users to the commit

Actual behavior: [What actually happens]

  • The pre-commit hook errors as above

Reproduces how often: [What percentage of the time does it reproduce?]

  • Every time

Versions

  • operating system and version: Mac (Apple Silicone); Monterey v12.6.2
  • git version 2.37.1
  • git version (git --version): 2.3.5

Additional Information

Improve detection of git directory

Steps to reproduce

  1. Go to a sub directory of a git repo
  2. Set or dissipate a mob (e.g. git mob ab or git solo)

Expected

git-mob or git-solo prints the current author and co-authors

Actual

Cannot find the commit template file.

Error: ENOENT: no such file or directory, open '.git/.gitmessage'

Let user know of latest release to git-mob

When git mob is used and a new release is out, a message should appear in the terminal to encourage the user to update. Also provide the command to update package.

We can constrain the check to every 24 hours from when the last check was performed.

Distributed git-mob suggest-coauthors does not have proper line endings on osx

Prerequisites

  • [Checked that your issue isn't already filed][git-mob issues]
  • Tried upgrading to the latest git-mob version (npm i -g git-mob)
  • Tried upgrading to the latest git version (brew upgrade git if installed with Homebrew/Linuxbrew)

Description

the bin directory has suggest-coauthors file with windows line ending on the shebang line even though I installed it on a mac

Steps to Reproduce

  1. yarn global add git-mob
  2. git-mob suggest-coauthors

Expected behavior: [What you expect to happen]
List of suggested coauthors

Actual behavior: [What actually happens]
env: node\r: No such file or directory

Reproduces how often: [What percentage of the time does it reproduce?]
100% of the time... until I edit the file to remove the spurious cr

Versions

  • operating system and version:
    macos catalina 10.15.6
  • git-mob version (git-mob --version):
    1.1.0
  • git version (git --version):
    2.27.0

Additional Information

Only add co-author from GitHub when it's desired

Summary

In my experience with my pairs, adding usernames from GitHub (#74) is always accidental.

Just to be super clear, here's an example:

Let's say I'm Jane Doe, and I'm pairing with Amy Doe and Bob Doe. I go to add them as pairs, expecting to see this:

$ git ad bd
Jane Doe <[email protected]>
Amy Doe <[email protected]>
Bob Doe <[email protected]>

But I haven't yet added them to ~/.git-coauthors, so instead I see:

$ git mob ad bd
Jane Doe <[email protected]>
Daniel Apatin <[email protected]>
Ben Dean <[email protected]>

I've inadvertently added GitHub users ad and bd. And this is persisted in ~/.git-coauthors file.

Motivation

Avoids confusion/frustration, especially for brand new users.

Describe alternatives you've considered

Additional context

Create gitmessage file specific to git-mob

Consider having git-mob use a unique gitmessage file rather than the standard filename gitmessage. When creating the file, it copies over the contents of the gitmessage file if present, then appends the co-authors.

Reduces risk, as we can safely delete git-mob's file when soloing. Otherwise it's not clear to git-mob if the file was created by itself or the user.

Use a new approach for identifying authors

We're using the same name and format for reading authors via a file like git-duet and git-pair does, i.e. .git-authors file. The reason we were doing this is to make the transition easier users.

But another option for easy transition is to provide a simple tool that converts the old file into a new file for git-mob. This way we aren't limited to a design which has certain drawbacks.

We won't need to use the same filename, since .git-authors historically also included the primary author. We could for example name it .git-coauthors to emphasise that it's strictly for co-authors.

We won't need to use YAML which means we can use JSON which will make git-mob commands quicker (don't need to load large third party dependencies which is very slow).

We also won't need to follow the same structure, for example, we can get rid of having multiple values on the same line (e.g. first_name last_name; email_id) which is confusing.

Provide a message flag for git mob

Summary

Provide another option to commit with co-authors by providing a message flag to run git commit with the message and co-authors.

$ git mob gg rk -m "This is a commit message"

Flag --message, -m message for git commit

Motivation

  • One command to append co-authors instead of running two

Extract code from bin directory into src directory

Summary

Some of the files in the bin directory are quite large. It would be good to simplify these by putting some functions into the src directory.

Motivation

It makes the code tidier. And hopefully it'll make the application quicker.

Support commits with inline message

Commits made with the -m or --message option won't have the editor invoked, so it won't read the commit template to prepopulate the commit message. That means git mob doesn't work with this style of committing.

Committing with an inline message is discouraged for many reasons, but it's still a common practice.

It'd be surprising behaviour if you're in a mob but an inlined commit doesn't have co-authors.

Support local git-authors file

Users may want to organise their mob co-authors per project, rather in a single global file.

If a local git-authors file exists, it should override the global file.

Committing inside a git submodule fails

Prerequisites

Description

Steps to Reproduce

Checkout git-mob at revision cd74de0. npm install; npm link.

cat <<-EOF > ~/.git-coauthors
{
  "coauthors": {
    "ad": {
      "name": "Amy Doe",
      "email": "[email protected]"
    },
    "bd": {
      "name": "Bob Doe",
      "email": "[email protected]"
    }
  }
}
EOF
cd ~/dev
mkdir parent-repo
git init
git submodule add [email protected]:findmypast-oss/git-mob.git child-repo
cd child-repo
git mob ad bd
git commit

Expected behavior: git opens up my $EDITOR with the Co-Authored-By trailers already in my commit message

Actual behavior:

fatal: could not read '.git/.gitmessage': Not a directory

Reproduces how often: Every time

Versions

  • operating system and version: macOS Mojave 10.14.2
  • git-mob version (git-mob --version): 0.4.0
  • git version (git --version): git version 2.20.1

Additional Information

git mob ad bd correctly updates the git config for the submodule at ~/dev/parent-repo/.git/modules/child-repo/config to include

[commit]
        template = .git/.gitmessage
[git-mob]
        co-author = Amy Doe <[email protected]>
        co-author = Bob Doe <[email protected]>

Here, .git/.gitmessage is a path I think is meant to be relative to the child
repository's root (~/dev/parent-repo/child-repo), and git does appear to be trying to read the file at ~/dev/parent-repo/child-repo/.git/.gitmessage.

However, because child-repo is a submodule, child-repo/.git is not a directory. The .gitmessage file is actually at ~/dev/parent-repo/.git/modules/child-repo/.gitmessage.

Make it easier to select co-author to pair with

Summary

It can be tricky to remember all your co-authors and it could be a better experience if you can have an interactive cli selector.

Motivation

This will reduce the cognitive load to remember your co-author list and reduce the number of commands to run to append co-author data.

Describe alternatives you've considered

Currently, you can run git mob -l and then you can run the mob command.

Ideas

Maybe Inquirer library can be used to create an interactive select cli command

Make it easier to get started by added .git-coauthors file after install

Summary

To help new users get started with Git Mob I think the .git-coauthors file should automatically be created with an example co-author included. After install the file is created and a message is printed out out explaining the next step which is adding co-authors to this file, including the path to it.

Motivation

I think this will help users get started efficiently and give confidence on what to do next. Creating a more positive experience might encourage people to share it.

Great migration to TypeScript

Summary

Move from JavaScript to TypeScript. Move over in an iterative fashion .js file in src folder needs to be migrated to a .ts with its appropriate types.

Don't have to do it all at once. Pick a file and make a PR when it's ready.

See this commit for example

Motivation

Improved code design with explicit types.

Store co-authors in git config

Investigate storing co-authors in the (global) git config. E.g.

[git-mob-coauthors]
  rk = Richard Kotze <[email protected]>
  ea = Elliot Alderson <[email protected]>

It's a simpler way to manage a list of authors because we can drop extra dependencies such as a separate file and a JSON parser. Users who store their .gitconfig in their dotfiles will have their co-authors become portable for free.

Do a benchmark, is there a noticeable difference in execution time?

Low priority, our current JSON solution has been working fine. But perhaps worth checking out before v1.

Follow-up would be to add co-authors via git-mob so users never have to switch context and edit a separate file.

Support default email domain

Users have to specify the email for every person. We could save them some keystrokes when they share the email domain (e.g. a popular public domain or coworkers).

Setting mob gives UnhandledPromiseRejectionWarning

Steps to reproduce:

  1. Remove the .git/.gitmessage file from the repo if it's present
  2. Set the mob with a co-author that exists in ~/.git-authors

Expected:

↪ git mob rk
Dennis Ideler <[email protected]>
Richard Kotze <[email protected]>

Actual:

↪ git mob rk
Dennis Ideler <[email protected]>
Richard Kotze <[email protected]>
(node:16471) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '.git/.gitmessage'
(node:16471) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16471) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code

Environment info:

↪ git rev-parse HEAD
ce80f51116290a3a61ad3e0c6390b228125ca085
↪ node -v
v8.9.1
↪ npm -v
5.6.0
↪ distro
NAME="Ubuntu"
VERSION="17.10 (Artful Aardvark)"

Overide default user

will be nice an option for override the default user.

we use a common Mac for IOS and we do mob programming bus the default user is not always the same

something like
git mob -o in1 in2 in3

set commiter as in1 and co author as in2 and in3

Amend co-authors on a commit?

Should we make an easy amend feature if a user realises they have committed the wrong or forgotten to add co-authors?

Perhaps something like: git mob rk di --amend - this will replace co-authors in the commit?

Warn user to uninstall git-duet

Because git-duet also has a git-solo command, so there will be a conflict and whichever script is present last in the PATH will be used.

Support multiple git trailers

Summary

Support multiple trailers that could be added to a commit message like:

  • Signed-off-by:
  • Reviewed-by:

Example cmd: git mob --type=si <author keys> all listed keys would apply Signed-off-by: trailer

Motivation

Help make it easy for everyone to use multiple types of trailers.

Ability to add coauthors via GitHub usernames or issue/pull request urls

Summary

Add the ability to add coauthors via GitHub usernames or issue/pull request urls using the GitHub REST API.

Motivation

Adding unknown people, especially if you don't know their emails, is time consuming. This feature would make it as simple as git add-coauthor ir introt, or git add-coauthor ir https://github.com/findmypast-oss/git-mob/issues/74.

Describe alternatives you've considered

Using an external tool.

Additional context

Reference implementation for API usage: https://gist.github.com/introt/ad30bcbdf789aed5bba43082741c7769

Global mob

Currently, mobs are set local per project. Users may want to have a mob set globally, where the mob stays the same as you switch between git repos.

Document code changes in releases

Add a tag comparison to the GitHub Releases so it's easier to see what's changed between versions.

Ideally this is automated by using the hooks from npm-version.

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.