Skip to content

add feature to find all tags referenced in a consuming project #14

@bicschneider

Description

@bicschneider

As a user I would like to understand from a consuming repo which releases/tags that are used. It can be a prequisite for clean-up

#!/bin/bash
set -euo pipefail

export subm_path=$1

for sha1_root in $(git rev-list --all -- ${subm_path}) ; do 
    sha1_sub="$(git ls-tree $sha1_root ${subm_path} | cut -d " " -f 3 | cut -d$'\t' -f 1 )" || true

    if [ -z "${sha1_sub:-}" ]; then
        sha1_sub="(no submodule)"
    else
        git -C ${subm_path} rev-parse --verify $sha1_sub > /dev/null 2>&1 || {
            git -C ${subm_path} fetch origin $sha1_sub > /dev/null
            git artifact fetch-tags -s $sha1_sub > /dev/null
            git -C ${subm_path} rev-parse --verify $sha1_sub > /dev/null 2>&1 || {
                sha1_sub_ls_remote="(dead sha1)"    
            }
        }

        sha1_sub_ls_remote=$(git -C ${subm_path} ls-remote --tags origin | grep $sha1_sub | cut -d / -f 3-) || true
        
        if [ -z "${sha1_sub_ls_remote:-}" ]; then
            sha1_sub_ls_remote="(no tag)"
        fi
    fi

    remote_branches_contains_count=$(git branch -r --contains $sha1_root | wc -l)
    tags_contains_count=$(git tag --contains $sha1_root | wc -l)
    
    printf "%14.14s %-60.60s %-80.80s %-20.20s\n" \
                "$sha1_sub" \
                "$sha1_sub_ls_remote" \
                "$(git log --oneline -1 --decorate $sha1_root | cut -c1-90)" \
                "(ct.br:$remote_branches_contains_count ct.t:${tags_contains_count})" \

done


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions