Skip to content

Commit

Permalink
Merge pull request #463 from VisionSystemsInc/master_main
Browse files Browse the repository at this point in the history
Master main
  • Loading branch information
andyneff authored Sep 14, 2023
2 parents d93a4b1 + b035ab8 commit 2fdbfc3
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ workflows:
filters:
branches:
only:
- master
- main
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|Linux|Windows|macOS|docs|
|--|--|--|--|
|[![CircleCI](https://circleci.com/gh/VisionSystemsInc/vsi_common.svg?style=shield)](https://circleci.com/gh/VisionSystemsInc/vsi_common)|[![Build status](https://ci.appveyor.com/api/projects/status/3a3hd3m41clxd5gw/branch/master?svg=true)](https://ci.appveyor.com/project/andyneff/vsi-common/branch/master)|[![Build Status](https://github.com/visionsystemsinc/vsi_common/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/VisionSystemsInc/vsi_common/actions)|[![Docs](https://img.shields.io/circleci/build/gh/VisionSystemsInc/vsi_common/master?label=docs)](https://visionsystemsinc.github.io/vsi_common)|
|[![CircleCI](https://circleci.com/gh/VisionSystemsInc/vsi_common.svg?style=shield)](https://circleci.com/gh/VisionSystemsInc/vsi_common)|[![Build status](https://ci.appveyor.com/api/projects/status/3a3hd3m41clxd5gw/branch/main?svg=true)](https://ci.appveyor.com/project/andyneff/vsi-common/branch/main)|[![Build Status](https://github.com/visionsystemsinc/vsi_common/actions/workflows/macos.yml/badge.svg?branch=main)](https://github.com/VisionSystemsInc/vsi_common/actions)|[![Docs](https://img.shields.io/circleci/build/gh/VisionSystemsInc/vsi_common/main?label=docs)](https://visionsystemsinc.github.io/vsi_common)|

In order to use these directories, all you have to do is

Expand All @@ -20,7 +20,7 @@ In order to use these directories, all you have to do is

* Python

* Prefered
* Preferred

```bash
pip install git+https://github.com/visionsystemsinc/vsi_common.git
Expand Down
2 changes: 1 addition & 1 deletion docker/blueprints
Submodule blueprints updated 0 files
2 changes: 1 addition & 1 deletion docker/recipes
12 changes: 6 additions & 6 deletions linux/git_functions.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ source "${VSI_COMMON_DIR}/linux/aliases.bsh"
# List all commits on branches/tags that have not been pushed to a remote. This is a set operation: it lists all the commits from a branch in the DAG except those reachable by a remote-tracking branch. It does not require an *associated* remote-tracking branch
#
# :Arguments: - [``$1``] - A name of a remote to filter by; e.g., origin. If unset, then don't filter
# - [``$2...``] - A branch/tag to filter by (or multiple branches/tags); e.g., master. If unset, then don't filter
# - [``$2...``] - A branch/tag to filter by (or multiple branches/tags); e.g., main. If unset, then don't filter
#
# :Output: - ``*stdout*`` - Print all unpushed commits for tracking branches to stdout
#
Expand Down Expand Up @@ -93,7 +93,7 @@ function _log_commits_helper()
#
# Get the corresponding remote-tracking branch for a local-tracking branch
#
# :Arguments: - ``$1`` - A local-tracking branch; e.g., master
# :Arguments: - ``$1`` - A local-tracking branch; e.g., main
#
# :Output: - ``*stdout*`` - The corresponding remote-tracking branch, or the empty string if there is no tracking branch
#
Expand Down Expand Up @@ -174,7 +174,7 @@ function git_tracking_branches()
#
# Alternatively,
# git for-each-ref --format='%(upstream:short) %(refname) %(upstream:track)' refs/heads
# where, for example, upstream:short=origin/master, refname=refs/heads/master
# where, for example, upstream:short=origin/main, refname=refs/heads/main
# and upstream:track=[ahead 3] or [gone] if the remote-tracking branch has
# been pruned. upstream:short is a blank space (' ') if upstream is unset,
# i.e., there is no remote-tracking branch setup
Expand Down Expand Up @@ -210,7 +210,7 @@ function git_tracking_branches()
#
# List all unpushed commits for a tracking branch to stdout
#
# :Arguments: - ``$1...`` - A local-tracking branch (or multiple branches); e.g., master
# :Arguments: - ``$1...`` - A local-tracking branch (or multiple branches); e.g., main
#
# :Output: - ``*stdout*`` - Print all unpushed commits for the tracking branch to stdout
#
Expand Down Expand Up @@ -1024,8 +1024,8 @@ function submodule-helper-relative-url()
mkdir -p "${sm_path}" .git/modules/"${sm_path}"/{objects,refs/heads}
# Strip trailing slash (not necessary, but easy)
echo "gitdir: ${up_path%/}/.git/modules/${sm_path}" > "${sm_path}"/.git
echo "ref: refs/heads/master" > .git/modules/"${sm_path}"/HEAD
echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" > .git/modules/"${sm_path}"/refs/heads/master
echo "ref: refs/heads/main" > .git/modules/"${sm_path}"/HEAD
echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" > .git/modules/"${sm_path}"/refs/heads/main

# from https://stackoverflow.com/a/37378302
"${GIT}" update-index --add --cacheinfo 160000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "${sm_path}" 1>/dev/null
Expand Down
30 changes: 18 additions & 12 deletions linux/git_mirror
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ GIT_MIRROR_SOURCE="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)"/"$(basename "${B
#
# Example usage:
#
# #. ``git_mirror mirror https://github.com/visionsystemsinc/vsi_common.git master`` - Mirror the repository and recursively create mirrors of all submodules currently in the master branch.
# #. ``git_mirror mirror https://github.com/visionsystemsinc/vsi_common.git main`` - Mirror the repository and recursively create mirrors of all submodules currently in the main branch.
# #. Transfer ``vsi_common_prep/transfer_{date}.tgz`` to your destination
# #. On the destination, create a directory, e.g., vsi_common_prep, and move the archive into it
# #. Extract the archive (the archive will extract directly into this directory)
Expand Down Expand Up @@ -433,7 +433,7 @@ function sync_submodules()
#
# Mirror the main repository and all submodules (recursively)
#
# Downloads a mirror of a git repository and all of its submodules. The normal ``git clone --mirror`` command does not support submodules at all. This at least clones all the submodules available in the specified branch (master by default).
# Downloads a mirror of a git repository and all of its submodules. The normal ``git clone --mirror`` command does not support submodules at all. This at least clones all the submodules available in the specified branch (git's init.defaultBranch by default).
#
# The script creates a directory, referred to as a prep directory (or prep_dir), which will contain all of the mirrored repositories plus a single ``transfer_{date}.tgz`` archive file containing all of these repositories, lfs objects, etc... Only this `tgz` file needs to be transferred to your destination.
#
Expand All @@ -444,7 +444,7 @@ function sync_submodules()
# After you have moved the transfer archive to its destination, you can use :func:`git_push_main` to push these mirrored repositories to a new git server.
#
# :Arguments: - ``$1`` - URL of the main git repository. On subsequent calls to this function, the prep (cache) dir created by this function can be used in lue of the repository's URL
# - [``$2``] - The git branch from which to identify the submodules. Default: master
# - [``$2``] - The git branch from which to identify the submodules. Default: git's init.defaultBranch
# :Parameters: [``GIT_MIRROR_PREP_DIR``] - The output directory in which to mirror the repositories; Default: ``${PWD}/{repo_name}_prep``
# :Output: - A prep directory which will contain all of the repositories plus a single ``transfer_{date}.tgz``
# - ``GIT_MIRROR_PREP_DIR`` - The path to the mirrored repositories
Expand All @@ -456,7 +456,7 @@ function sync_submodules()
#
# .. code-block:: bash
#
# git_mirror_main https://github.com/visionsystemsinc/vsi_common.git master
# git_mirror_main https://github.com/visionsystemsinc/vsi_common.git main
# # produces ./vsi_common_prep/transfer_2020_03_02_14_16_09.tgz
#
# .. rubric:: Example
Expand All @@ -483,7 +483,7 @@ function sync_submodules()
#
# .. note::
#
# ``git_mirror_main`` does not mirror all submodules that have ever been part of the repo, only those from a specific branch/SHA/tag you specify (master by default). This is because trying to mirror all submodules from the past could be very lengthy, and is very likely to include URLs that do not exist anymore.
# ``git_mirror_main`` does not mirror all submodules that have ever been part of the repo, only those from a specific branch/SHA/tag you specify (git's init.defaultBranch by default). This is because trying to mirror all submodules from the past could be very lengthy, and is very likely to include URLs that do not exist anymore.
#
# .. rubric:: Bugs
#
Expand All @@ -501,20 +501,20 @@ function git_mirror_main()
#
# Mirror the main repository and all submodules (recursively)
#
# Downloads a mirror of a git repository and all of its submodules. The normal ``git clone --mirror`` command does not support submodules at all. This at least clones all the submodules available in the specified branch (master by default).
# Downloads a mirror of a git repository and all of its submodules. The normal ``git clone --mirror`` command does not support submodules at all. This at least clones all the submodules available in the specified branch (git's init.defaultBranch by default).
#
# Creates a directory, referred to as a prep directory (or prep_dir), which will contain all of the mirrored repositories. Subsequent calls to :func:`git_mirror_repos` can use the existing prep directory as cache, updating faster than the first time.
#
# :Arguments: - ``$1`` - URL of the main git repository. On subsequent calls to this function, the prep (cache) directory created by this function can be used in lue of the repository's URL
# - [``$2``] - The git branch from which to identify the submodules. Default: master
# - [``$2``] - The git branch from which to identify the submodules. Default: git's init.defaultBranch
# :Parameters: [``GIT_MIRROR_PREP_DIR``] - The output directory in which to mirror the repositories; Default: ``${PWD}/{repo_name}_prep``
# :Output: - A prep directory which will contain all of the repositories
# - ``GIT_MIRROR_PREP_DIR`` - The path to the mirrored repositories
# - ``GIT_MIRROR_MAIN_REPO`` - The main repository's name. Based off of ``$1``; e.g., vsi_common if the URL is https://github.com/VisionSystemsInc/vsi_common.git
#
# .. note::
#
# :func:`git_mirror_repos` does not mirror all submodules that have ever been part of the repo, only those from a specific branch/SHA/tag you specify (master by default). This is because trying to mirror all submodules from the past could be very lengthy, and is very likely to include URLs that do not exist anymore.
# :func:`git_mirror_repos` does not mirror all submodules that have ever been part of the repo, only those from a specific branch/SHA/tag you specify (git's init.defaultBranch by default). This is because trying to mirror all submodules from the past could be very lengthy, and is very likely to include URLs that do not exist anymore.
#
# .. rubric:: Bugs
#
Expand Down Expand Up @@ -544,7 +544,13 @@ function git_mirror_repos()
else
GIT_MIRROR_MAIN_REPO="${1}"
fi
local BRANCH="${2-master}"

local BRANCH="${2-}"
# Use git's init.defaultBranch default value. If it is unset, the default is
# still master in the latest git
if [ -z "${BRANCH}" ]; then
BRANCH=$("${GIT}" config --get init.defaultBranch) || BRANCH=master
fi

local MAIN_DIR="$(basename "${GIT_MIRROR_MAIN_REPO}")"
MAIN_DIR="${MAIN_DIR%.*}"
Expand Down Expand Up @@ -1013,11 +1019,11 @@ function git_push_main()
#
# Tag the refs in the mirrored repository and all submodules
#
# Before pushing the mirrored repository and all of its submodules to the new git server with :func:`git_push_main`, tag the refs so that if, during the **next** transfer, they become dereferenced (due to a force push, which is sometimes necessary), they are not lost. For a ref of the form refs/heads/master, this (annotated) tag takes the (long) form of refs/tags/just_git_mirror/{datetime}/heads/master
# Before pushing the mirrored repository and all of its submodules to the new git server with :func:`git_push_main`, tag the refs so that if, during the **next** transfer, they become dereferenced (due to a force push, which is sometimes necessary), they are not lost. For a ref of the form refs/heads/main, this (annotated) tag takes the (long) form of refs/tags/just_git_mirror/{datetime}/heads/main
#
# :Arguments: ``$1`` - A file specifying the mapping between each repository and its mirror URL; see :func:`_git_mirror_load_info`
# ``$2`` - The mirrored repositories (extracted from the archive) created by :func:`git_mirror_main`
# :Parameters: [``GIT_MIRROR_TAG_REFS_REGEX``] - An extended regular expression specifying which refs to tag. The refs should be matched in their long form, e.g., refs/heads/master or refs/tags/v1.0.0. Default: ^refs/heads/.+
# :Parameters: [``GIT_MIRROR_TAG_REFS_REGEX``] - An extended regular expression specifying which refs to tag. The refs should be matched in their long form, e.g., refs/heads/main or refs/tags/v1.0.0. Default: ^refs/heads/.+
#
# .. seealso::
#
Expand Down Expand Up @@ -1073,7 +1079,7 @@ function git_tag_main()
# [1] https://git-scm.com/book/en/v2/Git-Basics-Tagging

# A ref is tagged with just_git_mirror/{date}/{namespaced_ref},
# where namespaced_ref is the long-form ref (e.g., refs/heads/master)
# where namespaced_ref is the long-form ref (e.g., refs/heads/main)
# with the refs/ domain stripped off
local namespaced_ref="${ref/refs\//}"
local SHA="$("${GIT}" show-ref --hash "${ref}")"
Expand Down
2 changes: 1 addition & 1 deletion linux/just_files/docker_functions.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ function Just-docker-compose()
function docker_service_running()
{
"${DOCKER}" inspect -f '{{.State.Status}}' \
$("${DOCKER_COMPOSE[@]}" ps -q ${@+"${@}"}) 2>/dev/null # noquotes
$("${DOCKER_COMPOSE[@]}" ps -qa ${@+"${@}"}) 2>/dev/null # noquotes
}

#**
Expand Down
2 changes: 1 addition & 1 deletion linux/just_files/just_diff
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fi
#
# .. code-block::
#
# just_diff "$(git rev-parse HEAD)" "$(git describe --abbrev=0 --tags origin/master)"
# just_diff "$(git rev-parse HEAD)" "$(git describe --abbrev=0 --tags origin/main)"
#
# Another use case, is in a ``just`` project, if you have checkout out the newest vsi_common commit, but not commit that change to the project:
#
Expand Down
6 changes: 3 additions & 3 deletions linux/just_git_airgap_repo.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ JUST_HELP_FILES+=("${BASH_SOURCE[0]}")
#
# This repository is now setup and can be mirrored and pushed to a new air-gapped git server:
#
# #. ``just git export-repo-guided`` - This target asks a series of questions and then mirrors the repository and its submodules (recursively). For this example, when prompted, we will, "Create a new mirror from a remote's URL", and save the the mirrored repositories to the output directory, ``{output_dir}``. In this case, because there is only a single remote, ``origin``, and a single branch, ``master``, they are chosen automatically.
# #. ``just git export-repo-guided`` - This target asks a series of questions and then mirrors the repository and its submodules (recursively). For this example, when prompted, we will, "Create a new mirror from a remote's URL", and save the the mirrored repositories to the output directory, ``{output_dir}``. In this case, because there is only a single remote, ``origin``, and a single branch, ``main``, they are chosen automatically.
#
# .. note::
# The mirror is created from (the URL of) the remote---not directly from this clone itself.
Expand Down Expand Up @@ -141,7 +141,7 @@ JUST_HELP_FILES+=("${BASH_SOURCE[0]}")
#
# 1. While the mirrored repository is a proper git repository, care must be taken to ensure subsequent (incremental) mirrors are successful: specifically, the transferred branches must remain read-only. However, additional branches/tags can be created as long as their names won't clash with those from the host repository.
#
# #. :func:`git_mirror git_mirror_main`, and by extension this plugin, does not mirror all submodules that have ever been part of the repo, only those from a specific branch/SHA/tag you specify (master by default). Consequently, checking out another version of the repository with a different version of the .gitmodules file in which a submodule has been deleted or renamed may cause the ``git_airgap-submodule-update`` to fail because the submodule's remote URL could not be re-configured to point to the mirror.
# #. :func:`git_mirror git_mirror_main`, and by extension this plugin, does not mirror all submodules that have ever been part of the repo, only those from a specific branch/SHA/tag you specify (git's init.defaultBranch by default). Consequently, checking out another version of the repository with a different version of the .gitmodules file in which a submodule has been deleted or renamed may cause the ``git_airgap-submodule-update`` to fail because the submodule's remote URL could not be re-configured to point to the mirror.
#
# .. seealso::
#
Expand Down Expand Up @@ -462,7 +462,7 @@ function relocate_git_defaultify()
echo " [-r|--remote-name] [-p|--prep-dir]"
echo " [-o|--output-dir] [-h|--help]"
echo
echo " -b, --branch The branch on which to base the mirror; e.g., master"
echo " -b, --branch The branch on which to base the mirror; e.g., main"
echo " -c, check-remote Ensure that changes to a submodule that are tracked"
echo " --no-check-remote by its parent have been pushed to the submodule's URL"
echo " -h, --help Print this help"
Expand Down
Loading

0 comments on commit 2fdbfc3

Please sign in to comment.