cali0707 / git-utils Goto Github PK
View Code? Open in Web Editor NEWA collection of useful git tools
License: Apache License 2.0
A collection of useful git tools
License: Apache License 2.0
I think there are three kinds of contributions we definitely want to be encouraging:
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
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.
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.
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)
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.
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:
git checkout --track "origin/${BRANCH}"
to get a copy of the branchWrite CONTRIBUTING.md to allow the new contributor easily get onboarded.
The contents include but not limited to:
Part of #4
Once the base functionality is working, we should add an option to stash changes before pushing to the remote.
Line 27 in d997ab1
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
It would be nice if we had a more cohesive README which also encourages users to star the repo
Line 43 in 69d2aca
If missing, what should people do next? Maybe provide more context here will be a great thing to have here.
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.
To use git-clonefork
, you need jq
installed. The install script should check if this is installed and tell you to install it if it isn't when trying to install git-clonefork
.
Lines 42 to 44 in 43dbb44
Change the error message to add the root directory.
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
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.
Have a tutorial on how to set up ssh key with GitHub
Part of #4
Once the base functionality of make-pr is complete, we should provide the option to specify a remote url.
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
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.