diff options
author | Rémy Coutable <remy@rymai.me> | 2018-07-24 13:17:52 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-07-24 13:17:52 +0000 |
commit | dc67cf1a62529bf7aecc8e350994ac40d5f4a068 (patch) | |
tree | 84ac83633d1029b9ce3400714e16f6220ee3a3a0 | |
parent | f59cd678e22c02a8f5a474bb982c22cdde0134c1 (diff) | |
parent | bcff3f3bb431c013000c83b6fce8f228429cf0d8 (diff) | |
download | gitlab-shell-dc67cf1a62529bf7aecc8e350994ac40d5f4a068.tar.gz |
Merge branch 'doc-go-update-vendor' into 'master'
Add script to update vendored go libs
See merge request gitlab-org/gitlab-shell!212
-rw-r--r-- | go/README.md | 12 | ||||
-rwxr-xr-x | support/go-update-vendor | 26 | ||||
-rw-r--r-- | support/go_build.rb | 4 |
3 files changed, 40 insertions, 2 deletions
diff --git a/go/README.md b/go/README.md index dfaa0da..6bbc03e 100644 --- a/go/README.md +++ b/go/README.md @@ -4,3 +4,15 @@ This directory contains Go executables for use in gitlab-shell. To add a new command `foobar` create a subdirectory `cmd/foobar` and put your code in `package main` under `cmd/foobar`. This will automatically get compiled into `bin/foobar` by `../bin/compile`. + +## Vendoring + +We use vendoring in order to include third-party Go libraries. This +project uses [govendor](https://github.com/kardianos/govendor). + +To update e.g. `gitaly-proto` run the following command in the root +directory of the project. + +``` +support/go-update-vendor gitlab.com/gitlab-org/gitaly-proto/go@v0.109.0 +``` diff --git a/support/go-update-vendor b/support/go-update-vendor new file mode 100755 index 0000000..020bb87 --- /dev/null +++ b/support/go-update-vendor @@ -0,0 +1,26 @@ +#!/usr/bin/env ruby + +require 'fileutils' + +require_relative 'go_build' +include GoBuild + +def main(dependency) + # Govendor wants to run in a GOPATH so let's make one for it. + create_fresh_build_dir + run!(GO_ENV, %w[go get github.com/kardianos/govendor]) + + gitlab_shell_build_go_dir = File.join(BUILD_DIR, 'src', GO_PACKAGE) + run!(GO_ENV, %W[govendor fetch #{dependency}], chdir: gitlab_shell_build_go_dir) + + # Now we have updated go/vendor in the temporary build dir. We must sync + # the changes back so that Git will see them. + FileUtils.rm_rf('go/vendor') + FileUtils.cp_r(File.join(gitlab_shell_build_go_dir, 'vendor'), 'go') +end + +unless ARGV.count == 1 + abort "usage: #{$PROGRAM_NAME} DEPENDENCY" +end + +main(ARGV.first) diff --git a/support/go_build.rb b/support/go_build.rb index 30a6b71..792ebc0 100644 --- a/support/go_build.rb +++ b/support/go_build.rb @@ -22,11 +22,11 @@ module GoBuild FileUtils.cp_r(File.join(ROOT_PATH, GO_DIR, '.'), build_source_dir) end - def run!(env, cmd) + def run!(env, cmd, options = {}) raise "env must be a hash" unless env.is_a?(Hash) raise "cmd must be an array" unless cmd.is_a?(Array) - unless system(env, *cmd) + unless system(env, *cmd, options) abort "command failed: #{env.inspect} #{cmd.join(' ')}" end end |