Midwest Dev Chat

MidwestDevChat.com

  • The newest 15 messages in the super-cool #git channel.

  • 12/31 11:17:53 Bernadine: Is there anything like a greater-than operator for `git checkout <ref>`? As in, `ref>=v1.x`.
  • 12/31 11:33:57 Elia: Not as far as I know. What would that command do, ideally?
  • 12/31 11:37:33 Elia: e.g. let's say I have this:
    | * 2c38b59 (feature/location) add location awareness
    |/  
    * 942d50f (HEAD -> master) initial commit
    and I do `git checkout ref>=942d50f`?
  • 12/31 11:47:57 Bernadine: So, the reason I ask is that Terraform uses git ref’s for module sources. https://www.terraform.io/docs/modules/sources.h... Within Terraform’s own providers, there is a notion of version constraints, e.g. `~> 1.2.0` https://www.terraform.io/docs/configuration/pro... Without an ability to say “greater-than” when sourcing terraform modules, I end up stuck on old versions of, e.g. https://github.com/GoogleCloudPlatform/terrafor... On the other hand, I don’t necessarily want to unpin the version entirely (bleeding edge might introduce a regression, say).
  • 12/31 11:49:03 Bernadine: It is also useful to have a version in my code as an indication of “this is what the version was when I originally wrote this”.
  • 12/31 11:56:05 Elia: With a big old disclaimer that I've never used it: `go get` puts some version range smarts on top of `git`. If `go get` actually uses a feature of `git` for that, you might be able to do the same thing
  • 12/31 11:56:27 Lupita: Bash can help with this, potentially
  • 12/31 11:56:51 Lupita: `git tag | grep v3. | tail -n 1 | xargs git checkout` Would check out the latest v3.x tag (or branch if you’d rather)
  • 12/31 11:57:49 Bernadine: hmm, `go get` is almost certainly what the provider commands use. So maybe the module commands need to be extended to do the same. That sounds like the correct way to approach the problem. Thanks!
  • 12/31 12:00:30 Elia: Can I make a suggestion? `git tag | grep v3. | sort --version-sort | tail -n 1 | xargs git checkout`
  • 12/31 12:00:46 Elia: That way 3.9 and 3.10 sort correctly
  • 12/31 12:02:05 Elia: Good luck!
  • 12/31 12:02:18 Lupita: wonderful! Thanks and TIL
  • 12/31 12:44:40 Giuseppe: `git log --since="dd-mm-yyyy" --reverse -n 1 --merges --ancestry-path master..942d50f` ? maybe adjust the `--merges` based on the project’s merge conventions and strategy for `master`. Did not test.
  • *Usernames have been changed to protect the innocent.
We're currently 1132 members strong. Join us!
Request Invite

Check out all the cool channels!

Join the conversation!