My first foray into my own open source project is a tool to lower the barrier to getting code up onto GitHub. I created it because I wanted to start a different open source project and in the process of learning what to do, realized that there are a number of repetitive steps. At first, I sought to create myself a set of scripts that would ease the process by interacting with the GitHub rest api and the dotnet core cli. Soon, I realized that taking these steps and creating a cross platform dotnet core global tool would both be better in terms of ease of use and also allow me to share this with the widest audience - hopefully saving someone else some time and tedium.
You can install it and try it yourself with
dotnet tool install --global gitstub
For issues, requests and ideas to make it better
GitStub on GitHub
You want to create a new dotnet core project so you
mkdir MyKillerWebApp cd MyKillerWebApp dotnet new webapp
Actually, it needs a solution and a little rearranging you decide
mkdir -p src/MyKillerWebApp mv * src/MyKillerWebApp dotnet sln -n MyKillerWebApp
Then you want to put it into a git repository, but first you need to find a
.gitignore to add - maybe you have one you used before in another project
cp /users/myuser/repos/someotherdotnetproject/.gitignore ./
Now you can set up your first commit
git init git add -A git commit -m "First Commit! The only way is up from here!"
At some point you realize, it should actually be a GitHub project, because you want to share this killer webapp with the world. From here, you go to your browser and GitHub.com, you log in, create a new project, filling out the details.
A few minutes later, the GitHub project is there, but it and your local git are not connected so you still have to
git remote add origin https://user:firstname.lastname@example.org/user/projectName.git git push --set-upstream origin master
Finally, you've got everything on GitHub and you can iterate from there.
Or maybe you stop somewhere before that, before even creating the local git repo. You tell yourself, "once it is 'worth it'" you'll take those steps and make a GitHub project. Then maybe you do, maybe you don't. Perhaps you get second thoughts - what if my code isn't 'good enough' yet. Sometimes though, code that is good enough or would be good enough just stays on your laptop, where it dies. Or another time, away from your machine, you are with another dev and you think - "Oh! I started working on something like this - but, ack, it's on my machine, so I'll have to go create a GitHub project and push it up for you to see it... maybe when I get back to my computer." Or maybe it's not that big of a barrier and you do go through those steps every time - but wouldn't it be nice if it was just a little faster, a little easier?
The goals of this project are two fold.
- Save time - simply put, these are repetitive tasks, they are begging for automation.
- Promote a development paradigm where you start projects, public or private, on GitHub and commit right away - GitHub-first.
- This not only makes the code immediately available everywhere, it also facilitates your progress in open source by having the initiation of the project start the cycle of contributions. You get to overcome your fear and perfectionism and replace it with continual public improvement as a feature of your dev life.
- By combining that with dotnet new project templates, you get a bootstrapped, scaffolded project up and ready to be iterated. The first commit is the template, outta the box. Your second commit will contain all the deltas between the base template and what value you've added thus far - and away ye go!
- Hopefully, it takes one small barrier out of the way that might stop you, on the margin, from trying something and putting it on GitHub because you "can't be bothered" to set up the project and connect everything.
First, install the tool using
dotnet tool install --global gitstub
Now, suppose I want to start a new console application in a folder called
From the command line in the that folder, I can
gitstub console -gsu myusername -gsp mypassword
gitstub will use the current folder as the name for a public project on GitHub. The two parameters after
console are my GitHub username (
-gsu) and GitHub password (
-gsp). This will do the stuff, including adding a .gitignore file that ignores most of the common things for dotnet projects. A few moments later, voila, I can now go to https://github.com/myusername/MyKillerApp and see everything there. If I open up the project in Visual Studio, I can proceed to use the Team Explorer window to process further commits.
Perhaps I want a little more structure with a solution/project laid out like
- <other files>
Then I can say
gitstub console --sln -gsu myusername -gsp mypassword
gitstub will create a solution and a project and arrange them thus.
If I had a different name I wanted to use for the project and solution, I can specify that as well
gitstub console -gsr "FirstKillerApp" -gss "KillerApps" -gsu myusername -gsp mypassword
If it needs to be a private repository, then I can add
gitstub console -gsr "FirstKillerApp" -gss "KillerApps" -gsu myusername -gsp mypassword --private
I can give the GitHub project a description and I can change the first commit message as well
gitstub console --sln -gsu myusername -gsp mypassword -gsd "The best app yet" -gsc "Initialized with the console template"
If my template has additional parameters, I can pass those along - any parameter not reserved for
gitstub will be passed to the
dotnet new command in original order, so
gitstub webapp -au Individual --sln -gsu myusername -gsp mypassword -gsd "Authed web app example" -gsc "Initialized with webapp and individual authentication"
dotnet new webapp -au Individual at the project creation step.
If I have an existing project, I can still use
gitstub to get things moving by including the
--existing switch. With this,
gitstub will skip the project/solution creation step and just commit what's already in the folder. It still adds the
.gitignore, so it won't pick up obj/bin/.vs and other stuff.
gitstub -gsu myusername -gsp mypassword --existing
You can follow along, post issues, feature requests, tell me how to be better at this open source thing, etc. at the GitHub repo.
In my sights for future features are
- getting rid of having to pass username and password each time by implementing GitHub OAuth and caching a token for the session.
devopsswitch that would create an Azure Devops project and connect it to the GitHub project
nugetswitch that would search the template output for a .nuspec file and modify it with the appropriate project repository and project name
I'm very open to feedback and suggestions, so let me know what you think!