Merge GitLab UI under packages/gitlab-ui
This merges gitlab-org/gitlab-ui> under the packages/gitlab-ui
path.
Move GitLab UI files to packages/gitlab-ui
This commit moves all tracked files to packages/gitlab-ui. This way, git log
and git blame
behaviour is sensible and useful, even in the GitLab history
and blame pages.
There are alternative approaches, for instance:
git merge --strategy-option=subtree=packages/gitlab-ui ...
git subtree add --prefix=packages/gitlab-ui ...
But they make such history opaque, since they create a new commit with all the files added from the latest state of the subtree.
For an example, take a look at gitlab-org/frontend/playground/design.gitlab.com@2d3e9481.
Commits
Move GitLab UI files to packages/gitlab-ui
This commit moves all tracked files to packages/gitlab-ui. This way, git log
and git blame
behaviour is sensible and useful, even in the GitLab history
and blame pages.
There are alternative approaches, for instance:
- git merge --strategy-option=subtree=packages/gitlab-ui ...
- git subtree add --prefix=packages/gitlab-ui ...
But they make such history opaque, since they create a new commit with all the files added from the latest state of the subtree.
This commit was created with this script:
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
GITLAB_UI_REMOTE_NAME=gitlab-ui-repo
GITLAB_UI_BRANCH_NAME=gitlab-ui-main
GITLAB_UI_TARGET_DIR=packages/gitlab-ui
warn() {
echo "$@" 1>&2
}
undo_everything() {
set +e
rm -rf "$GITLAB_UI_TARGET_DIR"
git checkout -f main
git branch --delete --force "$GITLAB_UI_BRANCH_NAME"
git remote remove "$GITLAB_UI_REMOTE_NAME"
set -e
exit
}
merge_gitlab_ui() {
# Add gitlab-org/gitlab-ui project commit history as separate branch
git remote add "$GITLAB_UI_REMOTE_NAME" https://gitlab.com/gitlab-org/gitlab-ui.git
git fetch --no-tags "$GITLAB_UI_REMOTE_NAME" main
git branch --no-track "$GITLAB_UI_BRANCH_NAME" "$GITLAB_UI_REMOTE_NAME/main"
# Move gitlab-ui repo files to subdirectory
git checkout "$GITLAB_UI_BRANCH_NAME"
mkdir -p "$GITLAB_UI_TARGET_DIR"
for path in $(git ls-files --cached); do
mkdir -p "$GITLAB_UI_TARGET_DIR"/"$(dirname "$path")"
mv "$path" "$GITLAB_UI_TARGET_DIR"/"$path"
done
# There should only be renamed files. If there are any added, deleted or
# whatever files, we've made a mistake.
rm -rf node_modules
git add . --force
if ! git diff --cached --diff-filter=r --quiet; then
warn "Aborting! There are some files that were not simply renamed:"
git diff --cached --diff-filter=r --name-status
exit 1
fi
# Commit changes
printf 'Move GitLab UI files to packages/gitlab-ui
This commit moves all tracked files to packages/gitlab-ui. This way, `git log`
and `git blame` behaviour is sensible and useful, even in the GitLab history
and blame pages.
There are alternative approaches, for instance:
- git merge --strategy-option=subtree=packages/gitlab-ui ...
- git subtree add --prefix=packages/gitlab-ui ...
But they make such history opaque, since they create a new commit with all the
files added from the latest state of the subtree.
This commit was created with this script:
```bash
%s
```
' "$(cat "${BASH_SOURCE[0]}")" | git commit --file=-
}
case "${1:-}" in
undo-everything)
warn "Undoing everything..."
undo_everything
;;
do-merge)
warn "Merging gitlab-ui and applying changes..."
merge_gitlab_ui
;;
*)
warn "Usage: $0 {do-merge|undo-everything}"
exit 1
;;
esac
... plus tens of thousands more from GitLab UI's main
branch.