Skip to content

Commit

Permalink
chore: move subtrees to subtrees/ subfolder
Browse files Browse the repository at this point in the history
closes #27

updated dev environment and githooks to work with new subtrees subfolder
updated docs on subtrees
  • Loading branch information
kriscoleman committed Jun 15, 2023
1 parent 9dc2edd commit 4e35b9a
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 23 deletions.
10 changes: 5 additions & 5 deletions .prepushrc.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'**/*.{js,jsx,ts,tsx}':
- npm run test:web
'archivista/**/*.go':
'subtrees/archivista/**/*.go':
- npm run test:archivista
'go-witness/**/*.go':
'subtrees/go-witness/**/*.go':
- npm run test:go-witness
'subtrees/witness/**/*.go':
- npm run test:witness
'judge-api/**/*.go':
- npm run test:judge-api
'witness/**/*.go':
- npm run test:witness
- npm run test:judge-api
62 changes: 62 additions & 0 deletions README.subtrees.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Subtrees

This monorepo contains a mix of internal private code and public open source code which we make available to the public.

The public open source code has been added to the project as [Git Subtrees](https://www.atlassian.com/git/tutorials/git-subtree).

## List of our subtrees

- <name-of-subtree> <path-to-subtree> <name-of-remote>
- `subtrees/archivista` `archivista/` `archivista`
- `subtrees/go-witness` `go-witness/` `go-witness`
- `subtrees/witness` `witness/` `witness`

## Getting Started

Assuming you have already gotten started with the root readme.md, then you can do the following:

1. `npm run remotes:add-all` this is a one time script to add all of our remotes. You'll only need to run it one time initially, and anytime we add more remote subtrees.
1. `npm run remotes:fetch-all` will fetch all the remote subtrees.

From there you can add more subtrees, update subtree subfolders, and/or update subtree parent repositories.

## Helper scripts

Review the scripts in our root `package.json` for helper scripts related to subtrees and remotes.

## Adding a subtree

You should add subtrees as remotes for easier management.

1. `git remote add -f <name-of-your-subtree> https://github.com/testifysec/some-great-open-source-project.git` with the name of your subtree and the https or ssh link to the git project
1. `git subtree add --prefix <path-to-your-subtree> <name-of-your-subtree> main --squash` will create an initial commit for your subtree into the monorepo project.

## Updating a subtree with upstream changes

So, some awesome soul decided to help us out and contributed open source changes to one of our subtrees!

Now what?

1. `git fetch <name-of-your-subtree> main`
1. `git subtree pull --prefix <path-to-your-subtree> <name-of-your-subtree> main --squash`

## Contributing internal changes back upstream to the subtree's true git repository

We can freely commit our fixes to the sub-project in our local working directory now.

So, you touched a subtree! Great work, we just made our open source project better.

Now what?

When it’s time to contribute back to the upstream project, we need to fork the project and add it as another remote:

1. `git remote add <name-of-your-fork> ssh://git@github.com/testifysec/some-great-open-source-project.git` to fork your changes into the subtree's true parent repository
1. `git subtree push --prefix <path-to-your-subtree> <name-of-your-fork> main`

## Review the Docs

Please [review the docs](https://gist.github.com/SKempin/b7857a6ff6bddb05717cc17a44091202) on [git subtree](https://www.atlassian.com/git/tutorials/git-subtree).

## Automate as much as we can, assist your fellow devs

As we learn and grow, we'll want to master managing these subtrees hygeniecally. Always offer tools and shortcuts for your fellow developers, and if we can, automate as much as we can.
8 changes: 4 additions & 4 deletions dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ load-attestations: copy-attestations build-archivistactl

build-witness:
mkdir -p ./bin
cd ../witness && go build -o bin/witness
mv ../witness/bin/witness ./bin/witness
cd ../subtrees/witness && go build -o bin/witness
mv ../subtrees/witness/bin/witness ./bin/witness

build-archivistactl:
mkdir -p ./bin
cd ../archivista && go build -o ./bin/archivistactl ./cmd/archivistactl/main.go
mv ../archivista/bin/archivistactl ./bin/archivistactl
cd ../subtrees/archivista && go build -o ./bin/archivistactl ./cmd/archivistactl/main.go
mv ../subtrees/archivista/bin/archivistactl ./bin/archivistactl

build-scribe:
mkdir -p ./bin
Expand Down
6 changes: 3 additions & 3 deletions dev/judge-platform.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"path": "../gitlab-runner"
},
{
"path": "../witness"
"path": "../subtrees/witness"
},
{
"path": "../go-witness"
"path": "../subtrees/go-witness"
},
{
"path": "../archivista"
"path": "../subtrees/archivista"
}
],
"settings": {
Expand Down
2 changes: 1 addition & 1 deletion dev/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build:
useBuildkit: false
artifacts:
- image: registry.gitlab.com/testifysec/judge-platform/archivista
context: "../archivista"
context: "../subtrees/archivista"
ko:
dir: "../archivista"
main: "../archivista/cmd/archivista"
Expand Down
15 changes: 5 additions & 10 deletions git-conventional-commits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,10 @@ changelog:
docs: Documentation
story: Stories
breakingChange: BREAKING CHANGES

## GitHub
# commitUrl: https://github.com/ACCOUNT/REPOSITORY/commit/%commit%
# commitRangeUrl: https://github.com/ACCOUNT/REPOSITORY/compare/%from%...%to%?diff=split

## GitHub - note, subtree commit links will point to monorepo and may not be the commit link we want in the changelog.
commitUrl: https://github.com/testifysec/judge/commit/%commit%
commitRangeUrl: https://github.com/testify/judge/compare/%from%...%to%?diff=split
## GitHub Issues
# issueRegexPattern: "#[0-9]+"
# issueUrl: https://github.com/ACCOUNT/REPOSITORY/issues/%issue%

## Jira Issues
# issueRegexPattern: "[A-Z][A-Z0-9]+-[0-9]+"
issueRegexPattern: "#[0-9]+"
issueUrl: https://github.com/testifysec/judge/issues/%issue%
# issueUrl: https://WORKSPACE.atlassian.net/browse/%issue%

0 comments on commit 4e35b9a

Please sign in to comment.