Skip to content

Commit 738bfda

Browse files
Merge pull request #15 from CodeMaster7000/CodeMaster7000-patch-1
Create Inactive-branches.sh
2 parents 549afbb + d854ed5 commit 738bfda

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Inactive-branches.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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

0 commit comments

Comments
 (0)