obsidiansystems / obelisk

Functional reactive web and mobile applications, with batteries included.
https://reflex-frp.org
BSD 3-Clause "New" or "Revised" License
960 stars 107 forks source link

Allow thunks to refer to detached heads #515

Open ORESoftware opened 5 years ago

ORESoftware commented 5 years ago

If we want to update to a specific hash:

ob deploy update --hash xyz

is there a way to do that? From what I know, ob deploy update always updates to the latest commit for a branch? But we want to update to a specific commit

ryantrinkle commented 5 years ago

Good idea!

ryantrinkle commented 5 years ago

ob thunk should also get the same feature

3noch commented 5 years ago

Ob thunks always track a branch. We should allow you to not track a branch which would allow not only hashes, but tags as well.

ryantrinkle commented 5 years ago

@3noch Yep, makes sense! ob thunk update and ob deploy update would need to have a sensible error message when they're not on a branch.

3noch commented 5 years ago

Put differently, this is a bigger feature than just adding a --hash option. It's a feature of ob thunks themselves.

ORESoftware commented 5 years ago

To make this request more specific - we want an ob deploy init directory to be able to update to a commit from any branch, not just a commit on a given/fixed branch.

So far we have had trouble getting commits from other branches, and I doubt I am the only one that struggled with the fact that we are limited to commits on the one branch.

ORESoftware commented 5 years ago

This feature will change our lives - we just want to be able to update an ob deploy init folder to accept any hash (from the remote, or any remote, really) not just the tip of a given branch.

Ericson2314 commented 5 years ago

You're lives shouldn't be changed too much by this feature because there is an easy workaround you can do until this is implemented. Clone the source repo and inside do git push <remote> <hash>:my-new-deploy-branch. Then use that branch.

ORESoftware commented 5 years ago

@Ericson2314 thanks I don't completely understand...so you are saying something like this:

ob deploy init  foo_folder
cd foo_folder
git clone <src>
git push origin  <hash>:branch

can you help me understand exactly? thanks

lgastako commented 5 years ago

Hopefully @Ericson2314 can confirm but I think in the scenario you're describing where you're ob deploy initing each time you can just switch to the branch you want in the app repo before you run ob deploy init. (Pulling etc if necessary). This will result in the branch you are on when you run ob deploy init being the one that's packaged into the src/git.json in the deploy dir.

If you wanted to update it manually you could check out the source repo in a new place then run ob thunk pack <your_src_dir>~ (egob thunk pack app`) and it would create a git.json that you could copy into the deploy dir.

lgastako commented 5 years ago

I described two possibilities -- one is checking out the proper version of the app repo before running ob deploy init and the other is running ob thunk pack on the entire source repo, i.e. the app directory. Your examples above show running ob thunk pack src in the deploy repo which is not one of those two things.

lgastako commented 5 years ago

It turns out I overcomplicated it and you can just do the thunk unpack, then check out the hash you want as a new branch, then push that branch to origin, and then pack it back up, which is what @Ericson2314 was describing.

ORESoftware commented 5 years ago

I deleted some of the noise that I added to the convo since it wasn't useful. To get back to the OP, I assume that this:

ob deploy update --hash X

will be a wrapper around something like this:

cd obdeployinitdir
ob thunk unpack src
cd src
git checkout -b deploythis X   # notice
git push -u  origin deploythis
cd ..
ob thunk pack src

however one problem that I suspect exists is that we cannot checkout a commit that was not on the original branch? or can we checkout any commit in the original repo?