how to update the vendor folder for https://github.com/hashicorp/terraform.git for terraform - go

Hi i am following steps given for hashicorp/terraform and performed below activity
# Get latest master branch's dependencies staged in local $GOPATH
git checkout master
git pull
godep restore -v
# Make your way to the dependency in question and checkout the target ref
pushd $GOPATH/src/github.com/some/dependency
git checkout [latest]
# Head back to Terraform on a feature branch and update the dependncy to the
# version currently in your $GOPATH
popd
git checkout my-feature-branch
godep update github.com/...
after this i can see my Godep.json file has been updated however i dont see changes in the vendor folder . it still points to old. Well i am looking emr support from vendor for that i am updating go-aws-sdk which is available with the latest go-aws-sdk. when i called go update github.com/... it has modified the godep.json but not vendor folder .
Could somebody please let me know the reason. Thanks

You have to do a godep restore -v again. update only updates the dependency in the Godep.json file.

Related

how to find out which git-branch a dependency in go.mod belongs to by command-line?

I want to write a shell program to check whether all go module dependencies in my project are on newest master version in their repositories. In particular, I want to know which branch each module is on. There is a file "go.mod" containing each dependency listed as {module}-{commit time}-{commit ID}. How can I get their git-branch name from SHA-1(commit id) or other message by shell program.
I have tried go list -m -u all, only showing the newest edition if the dependency is not up-to-date. etc. git.xxx.com/project v0.0.0-20191119034146-e894bf51bdcd [v0.0.0-20200609070643-fd412b12b811]. Without cloning the repos, can go module tools resolve this quetion?
I couldn't figure out how to find which branch the current dependency belongs to using only go tools. But there is a way to find which branch the commit is on using git.
git clone <repo-url> && cd <repo> && git branch -a --contains <commit>
Reference: Finding what branch a Git commit came from

Why does Go-get ask me to pick a branch?

I want to install mongoDB-driver. When I type this command
go get go.mongodb.org/mongo-driver/mongo
I got :
# cd /Users/jiangwei/go/src/go.mongodb.org/mongo-driver; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
package go.mongodb.org/mongo-driver/mongo: exit status 1
Probably because you've already checked out that repo into your Go path, and have changed to a non-default branch. The simplest way to correct it would be to remove that repo, and start from scratch.
rm -rf $(go env GOPATH)/src/go.mongodb.org/mongo-driver
Of course, this will lose any changes you've made in that repo.

how to 'go get' files in a different branch in github repo other than master

I need to go get following files from this repo
go get github.com/mattes/migrate/driver/mysql
but those files are in a different branch, not in master. How can I go get those files? I tried following way but it didn't get those files that I need.
go get gopkg.in/mattes/migrate.v1
Appreciate any help.
This is not supported by go get, you need to download the files manually to your GOPATH or to your vendor/ folder.
A vendor solution:
git clone git#github.com:mattes/migrate.git
vendor/github.com/mattes/migrate;
cd vendor/github.com/mattes/migrate;
git checkout BRANCH_NAME;

Godep restore doesn't use the code saved in _workspace

I started using godep a while ago but I think I'm failing to understand the principal, and I may be using it incorrectly entirely.
I thought godep maintains _workspace in order to have a local copy of the packages in case some revisions/projects are removed or become unavailable. But godep restore doesn't seem to use _workspace at all.
Also, calling godep save for the second time didn't update _workspace, only Godeps.json.
What am I missing?
UPDATE:
To explain my question I changed one of the revisions in my Godeps.json to an invalid revision "1" and ran godep restore. Here's the error I got:
$GOPATH/bin/godep restore
# cd /home/iliga/gopath/src/github.com/jinzhu/gorm; git pull --ff-only
From https://github.com/jinzhu/gorm
a97a508..087b708 master -> origin/master
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.
git pull <remote> <branch>
# cd /home/iliga/gopath/src/github.com/jinzhu/gorm; git checkout 1
error: pathspec '1' did not match any file(s) known to git.
godep: restore: exit status 1
As explained above, I would expect there to be no error and for godep to simply copy the code from _workspace.
"godep restore" does not use _workspace. It reads Godeps.json and check out your dependencies to GOPATH.
To use _workspace, you run go command prefixed with godep, like "godep go build", "godep go test".

Github. How do I make changes to what is ignored via .gitignore?

I have an Xcode project that uses git for version control. I have a .gitignore file to ignore the build subdirectory:
build/*
I recently added a subdirectory that contains an Xcode project and forgot to update the .gitignore file before checking it in.
Is there any way to make git ignore the build subdirctory now, after the fact?
Thanks,
Doug
git rm --cached dirToignore
echo dirToignore >>.gitignore
From there, a new commit will record that:
dirToignore is no longer par of versioned data
dirToIgnore won't show up anymore in git status
See this SO question for similar advices.
If you want to amend previous commit in order to remove said subdirectory from an old commit, see this SO question:
git commit --amend
can help you remove it from at least the last commit.

Resources