orbitalci / orbital

Orbital is a self-hosted CI system for solo/small consulting dev teams. Written in Rust.
GNU General Public License v3.0
29 stars 2 forks source link

Ocelot build -branch <branch> - doesn't respect the branch parameter. Uses current checkout #199

Closed tjtelan closed 4 years ago

tjtelan commented 5 years ago

In this case, my remote origin only has one branch: master. That branch has an ocelot.yml, and is supported just fine for ocelot.

Locally, I have just recently moved into a new branch with git checkout -B tj. But then I run ocelot build -branch master expecting that I want to kick off a build of whatever is the latest commit in the master branch.

stdout:

no -hash flag passed, using detected hash origin/tj
Flag -acct-repo was not set, detecting account and repository using git commands
Detected <account>/<repo> of level11consulting/petoolbox
Flag -vcs-type not set, detecting from git origin url
Detected vcs type of BITBUCKET
Searching for VCS creds belonging to level11consulting/petoolbox...
Successfully found VCS credentials belonging to level11consulting/petoolbox ✓
Validating VCS Credentials...
Successfully used VCS Credentials to obtain a token ✓
There are no previous builds starting with hash origin/tj...
Building with given hash origin/tj and branch master
Retrieving ocelot.yml for level11consulting/petoolbox...

stderr:

There was an error running git rev-parse command to find the most recently pushed commit:  exit status 128
ocelot.yml not found at commit origin/tj for Acct/Repo level11consulting/petoolbox
tjtelan commented 5 years ago

The branch doesn't seem to matter.

My remote branch from the original post is now pushed remote. But when I am checked out in that branch, and I run ocelot build -branch master, it builds the latest commit from the branch I've got checked out.

[...]
| 2544     | petoolbox | 2 minutes and 7 seconds  | Fri Feb 1 16:43:29  | PASS   | master | abcdcommithash |
| 2541     | petoolbox | 0 seconds                | Fri Feb 1 10:52:04  | PASS   | tj     | abcdcommithash |

[...]
tjtelan commented 5 years ago

We need to change the checkout pattern to first git checkout <branch, then reset head to the commit hash.

If we still end up in detatched HEAD, then that commit doesn't belong to the branch specified. Which is a user-error. (Don't block though.)