File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ echo " Enter repository to check inactive branches: "
3
+ read repo_name
4
+ echo " Enter username: "
5
+ read user_name
6
+ echo " Enter password: "
7
+ read -s password
8
+ presentdate=` date +' %s' `
9
+ list_of_branches=$( curl -s -u $user_name :$password https://api.github.com/repos/$user_name /$repo_name /branches | jq ' .[].name' )
10
+ for branch in $list_of_branches ; do
11
+ api_branch_name=$( echo $branch | cut -d' "' -f 2)
12
+ last_updated_date=$( curl -s -u $user_name :$password https://api.github.com/repos/$user_name /$repo_name /branches/$api_branch_name | jq ' .commit.commit.author.date' )
13
+ api_last_updated_date=$( echo $last_updated_date | cut -d' "' -f 2)
14
+ last_updated_date_sec=$( date -d $api_last_updated_date +%s)
15
+ numberofdays=$(( ($presentdate - $last_updated_date_sec )/ (60 * 60 * 24 ) ))
16
+ if [ $numberofdays -gt 60 ] ; then
17
+ echo " Branch $api_branch_name was last updated $numberofdays days ago."
18
+ fi
19
+ done
You can’t perform that action at this time.
0 commit comments