Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a terminal to the IDE - in the sky #4

Open
14 tasks
lakruzz opened this issue Nov 1, 2023 · 0 comments
Open
14 tasks

Add a terminal to the IDE - in the sky #4

lakruzz opened this issue Nov 1, 2023 · 0 comments
Labels
Template Template issue

Comments

@lakruzz
Copy link
Member

lakruzz commented Nov 1, 2023

After a bit of trial and beta back and forth GitHub CodeSpaces are now available for free to all GitHub users. CodeSpaces are essentially next step from the web based VS Code editor we've already explored. The addition is that we now also have access to an actual linux terminal.

In this issue:

  • Start a Code Space
  • Work from there as if it was your own PC - but in a shared setup
  • Open a new development branch on an issue - from the command line
  • Tweak the CodeSpace to your team's standards by adding a .devcontainer configuration

You can see you current CodeSpaces from https://github.com/codespaces This follows the well known GitHub standard, that you access personal information from global URLs - when you are logged in:

https://github.com/issues
https://github.com/settings
https://github.com/notifications
https://github.com/codespaces

Create a new CodeSpace on this repo

  • 👉 You go to Code panel, hit the Code button, Select the CodeSpace tab and then create a CodeSpace 👈

When the CodeSpace is done building you'll see a full fledged IDE environment - it look like the one we explored earlier in the web based editor, only this time you have a genuine linux terminal in the bottom - as if your were on your own machine.

  • 👉 run a few familiar commands; ls, gh, env, cat R<TAB>, git log, az and docker run hello-world 👈

It feels like home eh? Even tab-completion, git, docker, gh is pre-installed. Well the Azure CLI az wasn't installed, but everything else was there.

Let's imagine that we're a development team who agrees that:

👮‍♀️ You must only make changes that are related to an issue.
👮‍♀️ Each issue must have its own dedicated development branch.
👮‍♀️ Work can only be added to the master branch through pull-requests.

If these are rules we should make it easy to follow them.

Now consider, that this issue you're looking at now - #4 instructs you to configure the CodeSpace in a way that ensures that.

  • The az CLI must be pre-installed
  • The GitLens VS Code extension by Kraken must be installed
  • A .gitconfig file must be added in the root of the repo, and it must become active

Let's do all this! it's easy!

  • 👉 In the CodeSpace go to the terminal and run the command listed below: 👈
gh issue develop 4 --checkout
image
  • 👉 In the command palette find the command that will Add Dev Container configuration 👈
  • 👉 In the list find and install the Azure CLI 👈
  • 👉 In the extension list find and add GitLens, Copilot and Copilot Chat to the Dev Container configuration 👈
  • 👉 Add the line listed below as the second-to-last line in the configuration - just before the last closing bracket } ⚠️ remember to add a comma , after the closing bracket above 👈
"postCreateCommand": "git config --local --get include.path | grep -e ../.gitconfig || git config --local --add include.path ../.gitconfig"

...and finally

  • 👉 Add a new file .gitconfig in the root of the repo and let it contain the following: 👈
.gitconf file
[core]
  editor = nano

[push]
  default = current

[alias]
  undo-commit = reset --soft HEAD^
  addremove = add -A
  recommit = commit -C HEAD --amend
  co = checkout
  st = status
  root =  rev-parse --show-toplevel
  tree = log --graph --full-history --all --color --date=short --pretty=format:\"%Cred%x09%h %Creset%ad%Cblue%d %Creset %s %C(bold)(%an)%Creset\"
  backward = checkout HEAD^1
  forward = !git checkout $(git log --all --ancestry-path ^HEAD --format=format:%H | tail -n 1)

You may want to test the new Dev Container configuration before you commit it?

  • 👉 In the command palette find the command that will Rebuild Dev Container configuration 👈
  • 👉 Perform some tests - a few ones are suggested below 👈

From the terminal test the following commands

git config --list --show-origin
git tree
az

Open the workflow .yml you created earlier and see that is gives you info about who committed it

Open the .gitconfig file you created - invoke the CoPilot Chat. Ask it to "Add the most commonly used aliases, but don't delete or overwrite any existing settings"

  • 👉 add, commit -m "related to #4" and push the development branch branch 👈
  • 👉 Create a pull request run: gh pr create --fill 👈
  • 👉 Run gh browse and finish the pull request from the web 👈
  • 👉 Come back to the CodeSpace and run the commands listed below: 👈
git co master
git pull
git branch -d 4
# After you've typed '4' use <TAB> to complete the branch name
@lakruzz lakruzz added the Template Template issue label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Template Template issue
Projects
None yet
Development

No branches or pull requests

1 participant