Skip to content

Instantly share code, notes, and snippets.

@feclare feclare/merge-edgex-go.sh
Last active Jan 17, 2018

Embed
What would you like to do?
#/bin/bash
# Script to merge all edgex go repos in only one
# It needs the git-subtree.sh command available at
# https://github.com/git/git/blob/master/contrib/subtree/git-subtree.sh
# Notes:
# - It keeps all the commit history (git log)
# But when you get the log from just a file or directory only new commits are
# shown (git log file_or_path)
# - git blame works
# - This script can be run at any time to get a merge of all the repos
set -e
mkdir edgex-go
cd edgex-go
git init .
cat > Makefile << EOF
.PHONY: build test
build:
go build ./cmd/export-client
go build ./cmd/export-distro
test:
go test \`glide novendor\`
EOF
git add Makefile
git commit -sm "Adding makefile"
cat >README.md <<EOF
# EdgeX Foundry Go Services
[![license](https://img.shields.io/badge/license-Apache%20v2.0-blue.svg)](LICENSE)
Go implementation of EdgeX services.
All edgex go [repos](https://github.com/edgexfoundry/) have been merged into this repo.
The script [merge-edgex-go.sh](https://gist.github.com/feclare/8dba191e8cf77864fe5eed38b380f13a) has been used to generate this repo.
## Install and Deploy
Currently only \`export-client\` and \`export-distro\` are functional. \`core-command\`, \`core-metadata\` and \`core-data\` can be compiled but doesn't have a command in cmd
To fetch the code and compile the microservices execute:
\`\`\`
go get github.com/feclare/edgex-go
cd $GOPATH/src/github.com/feclare/edgex-go
glide install
make build
\`\`\`
## Community
- Chat: https://chat.edgexfoundry.org/home
- Mainling lists: https://lists.edgexfoundry.org/mailman/listinfo
## License
[Apache-2.0](LICENSE)
EOF
git add README.md
git commit -sm "Adding README"
git remote add core-domain https://github.com/edgexfoundry/core-domain-go
git fetch -a core-domain
git-subtree.sh add -P core/domain core-domain master
git remote add core-clients https://github.com/edgexfoundry/core-clients-go
git fetch core-clients
git-subtree.sh add -P core/clients core-clients master
git remote add core-command https://github.com/edgexfoundry/core-command-go
git fetch core-command
git-subtree.sh add -P core/command core-command master
git remote add core-data https://github.com/edgexfoundry/core-data-go
git fetch core-data
git-subtree.sh add -P core/data core-data master
git remote add core-metadata https://github.com/edgexfoundry/core-metadata-go
git fetch core-metadata
git-subtree.sh add -P core/metadata core-metadata master
git remote add support-domain https://github.com/edgexfoundry/support-domain-go
git fetch support-domain
git-subtree.sh add -P support/domain support-domain master
git remote add consul-client https://github.com/edgexfoundry/consul-client-go
git fetch consul-client
git-subtree.sh add -P support/consul-client consul-client master
git remote add support-logging-client https://github.com/edgexfoundry/support-logging-client-go
git fetch support-logging-client
git-subtree.sh add -P support/logging-client support-logging-client master
git remote add support-notifications-client https://github.com/edgexfoundry/support-notifications-client-go
git fetch support-notifications-client
git-subtree.sh add -P support/notifications-client support-notifications-client master
git remote add export-go https://github.com/edgexfoundry/export-go
git fetch export-go
git-subtree.sh add -P export export-go master
# Another method that didn't work, duplicated files in root and prefix
# git remote add core-clients https://github.com/edgexfoundry/core-clients-go
# git fetch core-clients
# git merge -s ours --no-commit --allow-unrelated-histories core-clients/master
# git read-tree --prefix=core/clients core-clients/master
# git commit -sm "Importing core-clients-go"
# git reset --hard
find -name "*.go" | xargs sed -i -e 's/github.com\/edgexfoundry\/consul-client-go/github.com\/edgexfoundry\/edgex-go\/support\/consul-client/'
find -name "*.go" | xargs sed -i -e 's/github.com\/edgexfoundry\/support-logging-client-go/github.com\/edgexfoundry\/edgex-go\/support\/logging-client/'
find -name "*.go" | xargs sed -i -e 's/github.com\/edgexfoundry\/core-clients-go/github.com\/edgexfoundry\/edgex-go\/core\/clients/'
find -name "*.go" | xargs sed -i -e 's/github.com\/edgexfoundry\/core-data-go/github.com\/edgexfoundry\/edgex-go\/core\/data/'
find -name "*.go" | xargs sed -i -e 's/github.com\/edgexfoundry\/core-domain-go/github.com\/edgexfoundry\/edgex-go\/core\/domain/'
find -name "*.go" | xargs sed -i -e 's/github.com\/edgexfoundry\/support-domain-go/github.com\/edgexfoundry\/edgex-go\/support\/domain/'
find -name "*.go" | xargs sed -i -e 's/github.com\/edgexfoundry\/support-notifications-client-go/github.com\/edgexfoundry\/edgex-go\/support\/notifications-client/'
find -name "*.go" | xargs sed -i -e 's/github.com\/edgexfoundry\/export-go/github.com\/edgexfoundry\/edgex-go\/export/'
git commit -sam "Replace edgex import path"
mkdir cmd
git mv export/cmd/client cmd/export-client
git mv export/cmd/distro cmd/export-distro
git commit -sam "Moved export commands to cmd"
git mv export/LICENSE .
find -name "LICENSE-2.0.txt" | xargs git rm
git commit -sm "Moving license file to root, removing duplicated license files"
mkdir docker
git mv export/Dockerfile.* docker/
git mv core/command/Dockerfile docker/Dockerfile.command
git mv core/metadata/Dockerfile docker/Dockerfile.metadata
git mv core/data/Dockerfile docker/Dockerfile.data
git commit -sm "Moving dockerfiles to ./docker"
glide create --non-interactive
git add glide.yaml
git commit -sm "Adding glide.yaml file"
glide install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.