github.com/git-lfs/git-lfs@v2.5.2+incompatible/script/changelog (about)

     1  #!/usr/bin/env bash
     2  #
     3  # Interactively generates a changelog over a range of commits:
     4  
     5  commit_summary() {
     6    local hash=$1
     7  
     8    pr=$(git show $hash | grep -o "#\([0-9]*\)" | cut -c 2-)
     9    prjson="$(curl -n https://api.github.com/repos/git-lfs/git-lfs/pulls/$pr 2>/dev/null)"
    10    title="$(echo $prjson | jq -r -e ".title")"
    11    id="$(echo $prjson | jq -r -e ".number")"
    12    author="$(echo $prjson | jq -r -e ".user.login")"
    13  
    14    # If the title begins with "Backport", then strip everything until the actual
    15    # pull-request title.
    16    if grep -q "Backport" <(echo $title); then
    17      title="$(echo $title | sed 's/^[^:]*: //g')"
    18    fi
    19  
    20    echo "* $title #$id (@$author)"
    21  }
    22  
    23  range=$1
    24  
    25  if [ "$range" = "" ]; then
    26    echo "Usage: $0 [options] base..next"
    27    exit 1
    28  fi
    29  
    30  features=""
    31  bugs=""
    32  misc=""
    33  
    34  for rev in $(git rev-list --merges --first-parent $range); do
    35    git show $rev
    36  
    37    processed=0
    38    while [ $processed -eq 0 ]; do
    39      echo "Categorize this change: [f,b,m,s,?] ?"
    40      read -n 1 opt
    41      echo ""
    42  
    43      case $opt in
    44        [fbms])
    45          processed=1
    46          ;;
    47        ?)
    48          echo "f - mark this merge as a feature"
    49          echo "b - mark this merge as a bugfix"
    50          echo "m - make this merge as a misc. change"
    51          echo "s - skip this merge, excluding it from the changelog"
    52          echo "? - display this help message"
    53          ;;
    54        *)
    55          echo "Unknown option: $opt, try again."
    56          ;;
    57      esac
    58    done
    59  
    60    if [ $opt != "s" ]; then
    61      summary="$(commit_summary $rev)"
    62    fi
    63  
    64    case $opt in
    65      f)
    66        features="$(printf "%s\n%s\n" "$features" "$summary")"
    67        ;;
    68      b)
    69        bugs="$(printf "%s\n%s\n" "$bugs" "$summary")"
    70        ;;
    71      m)
    72        misc="$(printf "%s\n%s\n" "$misc" "$summary")"
    73        ;;
    74    esac
    75  done
    76  
    77  echo "" >&2
    78  
    79  cat <<- EOF
    80  ### Features
    81  $features
    82  
    83  ### Bugs
    84  $bugs
    85  
    86  ### Misc
    87  $misc
    88  EOF