Skip to content

dev/sg: add update and update -local command

Warren Gifford requested to merge sg-upgrade into main

Created by: bobheadxi

Potentially a first step towards https://github.com/sourcegraph/sourcegraph/issues/29619 . Introduces a more ergonomic upgrade experience with sg update:

  • fetch main
  • stash changes (if any)
  • check out main
  • install
  • restore workspace
❯ sg update -h
USAGE
  sg update

Update local sg installation with the latest changes. To see what's new, run:

  sg version changelog -next

Requires a local copy of the 'sourcegraph/sourcegraph' codebase.

FLAGS
  -local=false  Update to local copy of 'dev/sg'

Test plan

Note that I've since changed the command name from upgrade to update, but some manual test runs:

~/Projects/sourcegraph/sourcegraph sg-upgrade
❯ ./dev/sg/install.sh   
Compiling...
          _____                    _____  
         /\    \                  /\    \  
        /::\    \                /::\    \  
       /::::\    \              /::::\    \  
      /::::::\    \            /::::::\    \  
     /:::/\:::\    \          /:::/\:::\    \  
    /:::/__\:::\    \        /:::/  \:::\    \  
    \:::\   \:::\    \      /:::/    \:::\    \  
  ___\:::\   \:::\    \    /:::/    / \:::\    \  
 /\   \:::\   \:::\    \  /:::/    /   \:::\ ___\  
/::\   \:::\   \:::\____\/:::/____/  ___\:::|    |  
\:::\   \:::\   \::/    /\:::\    \ /\  /:::|____|  
 \:::\   \:::\   \/____/  \:::\    /::\ \::/    /  
  \:::\   \:::\    \       \:::\   \:::\ \/____/  
   \:::\   \:::\____\       \:::\   \:::\____\  
    \:::\  /:::/    /        \:::\  /:::/    /  
     \:::\/:::/    /          \:::\/:::/    /  
      \::::::/    /            \::::::/    /  
       \::::/    /              \::::/    /  
        \::/    /                \::/____/  
         \/____/  
  
                                                  
  sg installed to /Users/robertlin/go/bin/sg
                                                  
                  Happy hacking!

  Run 'sg version changelog' to see what has changed.

~/Projects/sourcegraph/sourcegraph sg-upgrade* 9s
❯ sg upgrade -local
⌛ Upgrading to local copy of 'dev/sg'...
Compiling...
          _____                    _____  
         /\    \                  /\    \  
        /::\    \                /::\    \  
       /::::\    \              /::::\    \  
      /::::::\    \            /::::::\    \  
     /:::/\:::\    \          /:::/\:::\    \  
    /:::/__\:::\    \        /:::/  \:::\    \  
    \:::\   \:::\    \      /:::/    \:::\    \  
  ___\:::\   \:::\    \    /:::/    / \:::\    \  
 /\   \:::\   \:::\    \  /:::/    /   \:::\ ___\  
/::\   \:::\   \:::\____\/:::/____/  ___\:::|    |  
\:::\   \:::\   \::/    /\:::\    \ /\  /:::|____|  
 \:::\   \:::\   \/____/  \:::\    /::\ \::/    /  
  \:::\   \:::\    \       \:::\   \:::\ \/____/  
   \:::\   \:::\____\       \:::\   \:::\____\  
    \:::\  /:::/    /        \:::\  /:::/    /  
     \:::\/:::/    /          \:::\/:::/    /  
      \::::::/    /            \::::::/    /  
       \::::/    /              \::::/    /  
        \::/    /                \::/____/  
         \/____/  
  
                                                  
  sg installed to /Users/robertlin/go/bin/sg
                                                  
                  Happy hacking!

  Run 'sg version changelog' to see what has changed.
✅ Upgrade succeeded!

~/Projects/sourcegraph/sourcegraph sg-upgrade*
❯ sg upgrade
⌛ Stashing workspace...
⌛ Setting workspace up for upgrade...
⌛ Upgrading to sg@09fda16d0260e3c0017cba09dfe02dec3adb3087...
Compiling...
          _____                    _____  
         /\    \                  /\    \  
        /::\    \                /::\    \  
       /::::\    \              /::::\    \  
      /::::::\    \            /::::::\    \  
     /:::/\:::\    \          /:::/\:::\    \  
    /:::/__\:::\    \        /:::/  \:::\    \  
    \:::\   \:::\    \      /:::/    \:::\    \  
  ___\:::\   \:::\    \    /:::/    / \:::\    \  
 /\   \:::\   \:::\    \  /:::/    /   \:::\ ___\  
/::\   \:::\   \:::\____\/:::/____/  ___\:::|    |  
\:::\   \:::\   \::/    /\:::\    \ /\  /:::|____|  
 \:::\   \:::\   \/____/  \:::\    /::\ \::/    /  
  \:::\   \:::\    \       \:::\   \:::\ \/____/  
   \:::\   \:::\____\       \:::\   \:::\____\  
    \:::\  /:::/    /        \:::\  /:::/    /  
     \:::\/:::/    /          \:::\/:::/    /  
      \::::::/    /            \::::::/    /  
       \::::/    /              \::::/    /  
        \::/    /                \::/____/  
         \/____/  
  
                                                  
  sg installed to /Users/robertlin/go/bin/sg
                                                  
                  Happy hacking!

  Run 'sg version changelog' to see what has changed.
✅ Upgrade succeeded!
⌛ Restoring workspace...
ℹ️ Workspace restored!

~/Projects/sourcegraph/sourcegraph sg-upgrade
❯ sg version changelog
Changes in sg release 5c166e94e349aa3297ef95dcab487527288112bb
 sg migration: prefer ENV vars from config, fallback to process env (#31926) 5c166e94e3 by Thorsten Ball, 28 hours ago
 golangci-lint: enable unparam linter (#31856) 8d3e231322 by Thorsten Ball, 29 hours ago
 migrator: Support privileged migrations (#31782) 4d73c91ac2 by Eric Fritz, 4 days ago
 dev/sg: rename sg check to sg lint (#31891) 1d524292bb by Robert Lin, 4 days ago
 migrations: Fix squashed migration data tables (#31685) 1146b52e0c by Eric Fritz, 7 days ago
 migration: Fix squashing tables defined as a row value (#31674) 66fc69bcd8 by Eric Fritz, 7 days ago

Also works with clean workspace:

~/Projects/sourcegraph/sourcegraph sg-upgrade
❯ git st
On branch sg-upgrade
nothing to commit, working tree clean

~/Projects/sourcegraph/sourcegraph sg-upgrade 9s
❯ sg upgrade
⌛ Setting up workspace for upgrade...
⌛ Upgrading to sg@09fda16d0260e3c0017cba09dfe02dec3adb3087...
Compiling...
          _____                    _____  
         /\    \                  /\    \  
        /::\    \                /::\    \  
       /::::\    \              /::::\    \  
      /::::::\    \            /::::::\    \  
     /:::/\:::\    \          /:::/\:::\    \  
    /:::/__\:::\    \        /:::/  \:::\    \  
    \:::\   \:::\    \      /:::/    \:::\    \  
  ___\:::\   \:::\    \    /:::/    / \:::\    \  
 /\   \:::\   \:::\    \  /:::/    /   \:::\ ___\  
/::\   \:::\   \:::\____\/:::/____/  ___\:::|    |  
\:::\   \:::\   \::/    /\:::\    \ /\  /:::|____|  
 \:::\   \:::\   \/____/  \:::\    /::\ \::/    /  
  \:::\   \:::\    \       \:::\   \:::\ \/____/  
   \:::\   \:::\____\       \:::\   \:::\____\  
    \:::\  /:::/    /        \:::\  /:::/    /  
     \:::\/:::/    /          \:::\/:::/    /  
      \::::::/    /            \::::::/    /  
       \::::/    /              \::::/    /  
        \::/    /                \::/____/  
         \/____/  
  
                                                  
  sg installed to /Users/robertlin/go/bin/sg
                                                  
                  Happy hacking!

  Run 'sg version changelog' to see what has changed.
✅ Upgrade succeeded!
⌛ Restoring workspace...
ℹ️ Workspace restored!

Merge request reports

Loading