juxt / edge

A Clojure application foundation from JUXT
https://juxt.pro/edge/
MIT License
506 stars 62 forks source link

git process for building upon Edge does not work as described #93

Closed pwhittin closed 5 years ago

pwhittin commented 5 years ago

Docs page https://juxt.pro/edge/docs/setup.html "How to build your own project upon Edge" provides instructions that seem to be incorrect.

Step 1: Using our Enterprise github a project named crux-imdb is created. Step 2: Clone the newly created crux-imdb, and enter its directory.

git clone git@github.corp.rlws.com:pauwhi/crux-imdb.git
cd crux-imdb
ls -lh
total 4.0K
-rw-rw-r-- 1 pauwhi pauwhi 35 Jun 25 08:42 README.md

Step 3: Add Edge to your project.

git remote add edge https://github.com/juxt/edge.git
git pull edge master
warning: no common commits
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 4643 (delta 7), reused 17 (delta 2), pack-reused 4614
Receiving objects: 100% (4643/4643), 2.24 MiB | 3.80 MiB/s, done.
Resolving deltas: 100% (2353/2353), done.
From https://github.com/juxt/edge
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> edge/master
fatal: refusing to merge unrelated histories

The idea that Edge is NOT a template, rather tooling that can be updated in the future, is FANTASTIC, but the git workflow to accomplish this goal is currently unclear.

How does one resolve the 'fatal: refusing to merge unrelated histories' error?

SevereOverfl0w commented 5 years ago

When you created the repo, did you allow github to create an initial commit? That would account for this issue. You can pass --allow-unrelated-histories to pull to allow it to work (although you will have to resolve conflicts in .gitignore potentially).

pwhittin commented 5 years ago

Yes, Enterprise github created a README.md file and committed it.

Using Enterprise github, a repository can be created without the creation of the README.md, and with no commit, an empty repository. The key is to NOT check the Initialize this repository with a README checkbox on the Enterprise github repository creation page.

I assume that a future execution of git pull edge master will fetch and merge any changes into my project.

This is FANTASTIC! Much better than a lein template approach.

SevereOverfl0w commented 5 years ago

Yeah, it's easier not to initialize the repo with a README. Although, in transitioning to Edge on projects I've used the unrelated-histories trick a few times!

I assume that a future execution of git pull edge master will fetch and merge any changes into my project.

There's a script in bin/update-edge that will do this for you, without assuming you've done git remote add. It will also do a "migration" if necessary (e.g. when I moved dependencies around, it rewrote them in your deps.edn).

I'll open a follow-up issues to track this sidenote for Github and also documenting the unrelated histories technique.

pwhittin commented 5 years ago

A colleague proposed the following git workflow, which "hides" the Edge commit history:

Step 1: Using Enterprise github's UI, create a project repository with a committed README.md file.

Step 2: Clone the project repository locally, and change to its directory.

git clone git@github.corp.rlws.com:pauwhi/crux-imdb.git
Cloning into 'crux-imdb'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.

cd crux-imdb

ls -lh
total 4.0K
-rw-rw-r-- 1 pauwhi pauwhi 35 Jun 25 09:45 README.md

Step 3: Using Enterprise github's UI, create an "update-edge" branch in the project repository, and check it out locally.

git pull origin
From github.corp.rlws.com:pauwhi/crux-imdb
 * [new branch]      update-edge -> origin/update-edge
Already up to date.

git checkout update-edge
Branch 'update-edge' set up to track remote branch 'update-edge' from 'origin'.
Switched to a new branch 'update-edge'

Step 4: Add Edge repository, and pull it into project repository.

git remote add edge https://github.com/juxt/edge.git

git pull edge master --allow-unrelated-histories
warning: no common commits                                                       
remote: Enumerating objects: 29, done.                                                            
remote: Counting objects: 100% (29/29), done.                                                  
remote: Compressing objects: 100% (20/20), done.                                    
remote: Total 4643 (delta 7), reused 17 (delta 2), pack-reused 4614                       
Receiving objects: 100% (4643/4643), 2.24 MiB | 3.61 MiB/s, done.                         
Resolving deltas: 100% (2353/2353), done.                                                
From https://github.com/juxt/edge                                                            
 * branch            master     -> FETCH_HEAD                                             
 * [new branch]      master     -> edge/master                                            
Merge made by the 'recursive' strategy.                                                   
 .gitignore                                                          |  10 +              
...
 create mode 100644 lib/edge.test-utils/src/edge/test/system.clj
 create mode 100644 lib/graphql-ws/deps.edn
 create mode 100644 lib/graphql-ws/src/juxt/edge/graphql_ws/core.cljs

Step 5: Push the Edge commits into the project repository's 'update-edge' branch.

git push origin
Counting objects: 4645, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1642/1642), done.
Writing objects: 100% (4645/4645), 2.24 MiB | 18.32 MiB/s, done.
Total 4645 (delta 2355), reused 4641 (delta 2353)
remote: Resolving deltas: 100% (2355/2355), done.
To github.corp.rlws.com:pauwhi/crux-imdb.git
   b1f71d8..8b267b0  update-edge -> update-edge

Step 6: Using Enterprise github's UI, create a New pull request, and Squash and merge it.

Repeat as desired in the future.

SevereOverfl0w commented 5 years ago

I believe this is equivalent to git pull --squash --allow-unrelated-history https://github.com/juxt/edge.git