Skip to content

Fix broken gdk init in origin/main

Ash McKenzie requested to merge ashmckenzie/fix-broken-gdk-init into main

What does this Merge Request do and why?

I'm an idiot 🤦 !2007 (merged) introduced a bug where the gdk init logic must live (for now) within the gem/bin/gem file because it needs to work within and outside of a GDK install directory:

0.2.12 - current gem on rubygems.org

$ gdk --version
GitLab Development Kit 0.2.12

$ gdk init
Cloning into '/private/tmp/gitlab-development-kit'...
remote: Enumerating objects: 7674, done.
remote: Counting objects: 100% (7674/7674), done.
remote: Compressing objects: 100% (1243/1243), done.
remote: Total 23951 (delta 7389), reused 6540 (delta 6427), pack-reused 16277
Receiving objects: 100% (23951/23951), 21.62 MiB | 2.32 MiB/s, done.
Resolving deltas: 100% (16351/16351), done.

0.2.13 - gem built from GDK origin/main (has not been uploaded to rubygems.org yet)

$ pwd
/Users/ash/src/gitlab/gitlab-development-kit

$ git co main
Already on 'main'
Your branch is up to date with 'origin/main'.

$ git pull -r
Already up to date.

$ cd gem

$ ls -la
total 16
drwxr-xr-x   6 ash  staff   192  2 Jun 16:25 .
drwxr-xr-x  99 ash  staff  3168  2 Jun 16:21 ..
-rw-r--r--   1 ash  staff   577 21 Dec 17:14 CHANGELOG
drwxr-xr-x   3 ash  staff    96  2 Jun 16:25 bin
-rw-r--r--   1 ash  staff   740  4 May 10:25 gitlab-development-kit.gemspec
drwxr-xr-x   3 ash  staff    96  2 Jun 16:25 lib

$ gem build
  Successfully built RubyGem
  Name: gitlab-development-kit
  Version: 0.2.13
  File: gitlab-development-kit-0.2.13.gem

$ gem install gitlab-development-kit-0.2.13.gem
Successfully installed gitlab-development-kit-0.2.13
Parsing documentation for gitlab-development-kit-0.2.13
Installing ri documentation for gitlab-development-kit-0.2.13
Done installing documentation for gitlab-development-kit after 0 seconds
1 gem installed

$ gdk --version
GitLab Development Kit 0.2.13

$ gdk init
ℹ️  'gdk init' is deprecated and will be removed in a future update.
Cloning into 'gitlab-development-kit'...
✅️ Successfully git cloned the GDK into 'gitlab-development-kit'.

# ☝️ works because we're within a GDK install, now let's try in /tmp

$ cd /tmp

$ gdk init

The current working directory is not inside a gitlab-development-kit
installation. Use 'cd' to go to your gitlab-development-kit or create
a new one with 'gdk init'.

gdk init [DIRECTORY] # Default: /private/tmp/gitlab-development-kit

# 😞

0.2.14 - gem built from GDK ashmckenzie/fix-broken-gdk-init (has not been uploaded to rubygems.org)

$ pwd
/Users/ash/src/gitlab/gitlab-development-kit

$ git co ashmckenzie/fix-broken-gdk-init
Switched to branch 'ashmckenzie/fix-broken-gdk-init'

$ cd gem

$ gem build
  Successfully built RubyGem
  Name: gitlab-development-kit
  Version: 0.2.14
  File: gitlab-development-kit-0.2.14.gem

$ ls -la
total 32
drwxr-xr-x   7 ash  staff   224  2 Jun 16:29 .
drwxr-xr-x  99 ash  staff  3168  2 Jun 16:27 ..
-rw-r--r--   1 ash  staff   577 21 Dec 17:14 CHANGELOG
drwxr-xr-x   3 ash  staff    96  2 Jun 16:29 bin
-rw-r--r--   1 ash  staff  5632  2 Jun 16:29 gitlab-development-kit-0.2.14.gem
-rw-r--r--   1 ash  staff   740  4 May 10:25 gitlab-development-kit.gemspec
drwxr-xr-x   3 ash  staff    96  2 Jun 16:29 lib

$ gem install gitlab-development-kit-0.2.14.gem
Successfully installed gitlab-development-kit-0.2.14
Parsing documentation for gitlab-development-kit-0.2.14
Installing ri documentation for gitlab-development-kit-0.2.14
Done installing documentation for gitlab-development-kit after 0 seconds
1 gem installed

$ gdk --version
GitLab Development Kit 0.2.14 (70397924)

$ gdk init
INFO: 'gdk init' is deprecated and will be removed in a future update.
Cloning into '/Users/ash/src/gitlab/gitlab-development-kit/gem/gitlab-development-kit'...
remote: Enumerating objects: 7674, done.
remote: Counting objects: 100% (7674/7674), done.
remote: Compressing objects: 100% (1243/1243), done.
remote: Total 23951 (delta 7389), reused 6540 (delta 6427), pack-reused 16277
Receiving objects: 100% (23951/23951), 21.62 MiB | 12.35 MiB/s, done.
Resolving deltas: 100% (16351/16351), done.
INFO: Successfully git cloned the GDK into '/Users/ash/src/gitlab/gitlab-development-kit/gem/gitlab-development-kit'.

$ cd /tmp

$ gdk init blah
INFO: 'gdk init' is deprecated and will be removed in a future update.
Cloning into 'blah'...
remote: Enumerating objects: 7674, done.
remote: Counting objects: 100% (7674/7674), done.
remote: Compressing objects: 100% (1243/1243), done.
remote: Total 23951 (delta 7389), reused 6540 (delta 6427), pack-reused 16277
Receiving objects: 100% (23951/23951), 21.62 MiB | 9.75 MiB/s, done.
Resolving deltas: 100% (16351/16351), done.
INFO: Successfully git cloned the GDK into 'blah'.

# 😰

Merge Request checklist

  • This change is backward compatible. If not, please include steps to communicate to our users.
  • Tests added for new functionality. If not, please raise Issue to follow-up.
  • Documentation added/updated, if needed.
  • gdk doctor test added, if needed.
  • Add the ~highlight label if this MR should be included in the CHANGELOG.md.
Edited by Ash McKenzie

Merge request reports

Loading