Giter Site home page Giter Site logo

git-utils's Issues

Make more welcoming to contributions

I think there are three kinds of contributions we definitely want to be encouraging:

  1. Recommendations for new git workflows to make commands for
  2. Bug reports
  3. PRs

We should update our README to reflect this, and maybe consider adding a CONTRIBUTING.md and direct people there. Another idea is to add issue templates for bugreports/feature requests

[Proposal]: Checkout PR command

Problem Description

Currently, if you need to check out a branch from a PR to test it locally, you need to figure out if it is on a fork or a branch that exists in the repo. Then, if it is a fork, you need to add a remote to that fork and then checkout the relevant branch.

Proposed solution

Add a command that would operate something like git checkout-pr <pr_url>, and figure out whether or not the branch referred to in the url is on a fork or the main repo. It would set up any necessary remote and then checkout the appropriate branch. It is also worth considering adding a "cleanup" command or option here, that removes the remote and deletes the branch once you are done.

Handle clonefork errors more gracefully

Currently, running git clonefork without any URL can cause a lot of confusing errors (see below). We should suppress these errors and provide a more clear error message to users.

~/Leo: git clonefork                                                      
curl: (2) no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
fatal: You must specify a repository to clone.

usage: git clone [<options>] [--] <repo> [<dir>]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --progress            force progress reporting
    --reject-shallow      don't clone shallow repository
    -n, --no-checkout     don't create a checkout
    --bare                create a bare repository
    --mirror              create a mirror repository (implies bare)
    -l, --local           to clone from a local repository
    --no-hardlinks        don't use local hardlinks, always copy
    -s, --shared          setup as shared repository
    --recurse-submodules[=<pathspec>]
                          initialize submodules in the clone
    --recursive ...       alias of --recurse-submodules
    -j, --jobs <n>        number of submodules cloned in parallel
    --template <template-directory>
                          directory from which templates will be used
    --reference <repo>    reference repository
    --reference-if-able <repo>
                          reference repository
    --dissociate          use --reference only while cloning
    -o, --origin <name>   use <name> instead of 'origin' to track upstream
    -b, --branch <branch>
                          checkout <branch> instead of the remote's HEAD
    -u, --upload-pack <path>
                          path to git-upload-pack on the remote
    --depth <depth>       create a shallow clone of that depth
    --shallow-since <time>
                          create a shallow clone since a specific time
    --shallow-exclude <revision>
                          deepen history of shallow clone, excluding rev
    --single-branch       clone only one branch, HEAD or --branch
    --no-tags             don't clone any tags, and make later fetches not to follow them
    --shallow-submodules  any cloned submodules will be shallow
    --separate-git-dir <gitdir>
                          separate git dir from working tree
    -c, --config <key=value>
                          set config inside the new repository
    --server-option <server-specific>
                          option to transmit
    -4, --ipv4            use IPv4 addresses only
    -6, --ipv6            use IPv6 addresses only
    --filter <args>       object filtering
    --also-filter-submodules
                          apply partial clone filters to submodules
    --remote-submodules   any cloned submodules will use their remote-tracking branch
    --sparse              initialize sparse-checkout file to include only files at root

usage: git remote add [<options>] <name> <url>

    -f, --fetch           fetch the remote branches
    --tags                import all tags and associated objects when fetching
                          or do not fetch any tag at all (--no-tags)
    -t, --track <branch>  branch(es) to track
    -m, --master <branch>
                          master branch
    --mirror[=(push|fetch)]
                          set up remote as a mirror to push to or fetch from

error: No such remote 'upstream'

Do you want to mute this error log and we have our own error log? The current log might cause some confusion to the user. What do you think @Cali0707

Originally posted by @Leo6Leo in #13 (comment)

Support non forked repos in `git-sync`

Currently, git-sync only works if I am syncing with a repo which is a fork. It should work if I am using it with a repo I own directly which is not a fork as well, and just fetch from origin if that is the case.

Support no local checkout of main/master branch in git sync

We currently are assuming that the user has a local checkout of main/master. This can lead to issues (as experienced by @inesqyx) where the script throws a lot of warnings/errors. We should update the script to:

  1. Check if there is a local copy of the branch `git branch -l "${BRANCH}"
  2. If not, run git checkout --track "origin/${BRANCH}" to get a copy of the branch

Write CONTRIBUTING.md

Write CONTRIBUTING.md to allow the new contributor easily get onboarded.

The contents include but not limited to:

  • Env setup
  • PR format
  • Coding convention
  • Workflow
  • ...

Make PR command

This command would just open the make PR window in the browser, sort of like if you clicked on the PR link when you first push a change to a new branch.

In order for this to be complete, the following tasks must be finished:

Auto create fork repo with GitHub API

Note: this command currently only works with github repositories!

https://docs.github.com/en/rest/repos/forks?apiVersion=2022-11-28#create-a-fork

And allowing git clonefork to detect, if the link provided is connected to a repo that is not created by the current user, we will automatically create a fork repo for them and do the remote config.

If the link provided is connected to a repo that is created by the current user, we will only do the remote config.
e.g:
git clonefork <upstream> will create the fork repo in my account
git clonefork <Leo6Leo/reponame> will not create the fork repo

Make README look better

It would be nice if we had a more cohesive README which also encourages users to star the repo

Missing bin path

echo "Your path is missing ~/bin, you might want to add it."

If missing, what should people do next? Maybe provide more context here will be a great thing to have here.

Add commit option to make-pr

Part of #4

Once the base functionality is complete, we should add an option to make a commit of any staged changes. The ordering should be commit, stash, push, open PR.

More detail in the installation error description

git-utils/install.sh

Lines 42 to 44 in 43dbb44

echo "If you use bash, add 'export PATH=\"\${PATH}:\${HOME}/bin\"' to your .bashrc file, and then run \"source .bashrc\""
echo "If you use zsh, add 'export PATH=\"\${PATH}:\${HOME}/bin\"' to your .zshrc file, and then run \"source .zshrc\""
echo "If you use fish, add 'fish_add_path -m ~/bin' to your config.fish file, and then run \"source config.fish\""

Change the error message to add the root directory.

Create install script

To make it easier to install the git utils, there should be an install script. I think that by default it should install all of the git utils, into ~/bin, but that if you do e.g. ./install.sh sync it would only install git sync

Add Gitlab support to git clonefork

Currently, the git clonefork command depends on the Github API, so it will not work for any Gitlab repositories. To rectify this, a check should be added to see whether or not a repository is on Github vs Gitlab. Then, code to call the Gitlab API properly should be added as well.

Make base git make-pr command

Part of #4

This issue is for the base make-pr command. It will open the PR UI in a browser, but won't support stashing or committing changes, or changing the remote. It will try and detect "upstream" for the remote, or if not use "origin" for the remote

Add cases for repos that has main branch named "master" in upstream for git sync

Currently, the script only works for users who interact with upstreams whose main branches are also named "main". However, if the main branches in their upstreams happen to be something else (i.e. master), the script will no longer work. Considering, there are a wide range of repos that named their main branches as "master"., there is a strong call for include this case in the automated script.

Support non-git url in git clonefork

git clonefork will currently only work if provided the .git url you get when trying to clone a git repository. However, I think it would be easier for users if we also supported the non-git url i.e. the url to the repo on GitHub.

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.