terra-ops / terra-cli

The Terra Command Line Interface
http://terra.readthedocs.org
GNU General Public License v2.0
48 stars 17 forks source link

issue #68, support for specifying git branches #69

Closed badri closed 8 years ago

jonpugh commented 8 years ago

Excellent, this is exactly what I was thinking.

There are a few changes I'd like to make before merging this:

badri commented 8 years ago

Thanks for the comments :+1: I thought naming "branch" to "version" would be a bit misleading, as we really mean git branches when we say branch. That's anyways my opinion. What do you think?

Also, I couldn't find a way to get the default branch of a repo without cloning it. That's why I had it as a two-fold step, to ask for a specific branch and if answered yes, clone it. Otherwise, it is going to clone the default branch anyways.

badri commented 8 years ago

Output of environment name checking:

$ terra environment:add
Which app? 
  [d7    ] d7
  [kalvi ] kalvi
 > kalvi
Environment name? foo-bar
 ERROR  Environment foo-bar cannot contain spaces or special characters.
Environment name? foo%bar
 ERROR  Environment foo%bar cannot contain spaces or special characters.
Environment name? foo bar     
 ERROR  Environment foo bar cannot contain spaces or special characters.
Environment name? foobar
Path: (/home/lakshmi/Apps/kalvi/foobar) 

Output of "branch" feature in env add:

$ terra environment:add
Which app? 
  [d7    ] d7
  [kalvi ] kalvi
 > kalvi
Environment name? foo
Path: (/home/lakshmi/Apps/kalvi/foo) 
Getting the default branch for badri@git.drupal.org:project/kalvi.git 
Version? [7.x-1.x]
Checking if branch 7.x-1.x exists in badri@git.drupal.org:project/kalvi.git 
Cloning into '/home/lakshmi/Apps/kalvi/foo'...
* 7.x-1.x
On branch 7.x-1.x
Your branch is up-to-date with 'origin/7.x-1.x'.

nothing to commit, working directory clean
Environment saved to registry.
jonpugh commented 8 years ago

Thanks @badri!! I've merged this work, with some commits afterwards for cleanup.

I've removed the logic for asking for branch and checking if it's valid. I appreciate the work, but I think it adds unnecessary complexity to this code.

Instead, use the option "--ref" if you want to create an environment with a specific branch, tag, or sha.

If you don't use the option, we just assume you want the default branch.

if you specify a ref that does not exist, we just ignore it and use the default branch.

Thanks a ton for this effort! Keep it coming! :+1: