Commit 6ced9bad authored by Aral Balkan's avatar Aral Balkan

The better/stat command now correctly displays status of specific domains.

parent 2f7b5303
Pipeline #477 skipped
......@@ -149,13 +149,13 @@ checkLocalExistence(){
local domainInDrafts="${draftsDirectory}/${domainWithCategory}"
if [ -d "${domainInContent}" ]; then
echo " ✓ Found in content (${domainInContent})."
echo " ✓ Found in content: ${domainInContent}"
else
echo " ✕ Not in content"
fi
if [ -d "${domainInDrafts}" ]; then
echo " ✓ Found in drafts (${domainInDrafts})"
echo " ✓ Found in drafts: ${domainInDrafts}"
else
echo " ✕ Not in drafts"
fi
......@@ -171,7 +171,6 @@ saveIssueIDs(){
}
ensurePersonIsLoggedIn(){
local privateTokenFile=~/better.fyi/.private/config/source.ind.ie-private-token
......@@ -191,8 +190,8 @@ checkIfIssueExists(){
if [ -n "$issue" ]; then
saveIssueIDs
issueTitle="source.ind.ie/better/content/issues/${issueIID}"
echo " ✓ Issue exists: https://${issueTitle}"
issueURL="source.ind.ie/better/content/issues/${issueIID}"
echo " ✓ Issue exists: https://${issueURL}"
#
# If the issue exists, we should also check for branch existence
......@@ -208,7 +207,7 @@ checkIfIssueExists(){
checkIfLocalBranchExists(){
localBranch=$(runIn $contentDirectory "git branch | grep ${issueTitle}")
localBranch=$(runIn $contentDirectory "git branch | grep ${issueURL}")
if [ -n "$localBranch" ]; then
......@@ -226,11 +225,11 @@ checkIfLocalBranchExists(){
checkIfRemoteBranchExists(){
remoteBranchExists=$(curl --silent -H "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/${contentRepositoryID}/repository/branches | $private/lib/jq --arg name "$issueTitle" --raw-output '.[] | select(.name == $name)')
remoteBranchExists=$(curl --silent -H "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/${contentRepositoryID}/repository/branches | $private/lib/jq --arg name "$issueURL" --raw-output '.[] | select(.name == $name)')
if [ -n "$remoteBranchExists" ]; then
comparisonURL="https://source.ind.ie/better/content/compare/master...${issueTitle}"
comparisonURL="https://source.ind.ie/better/content/compare/master...${issueURL}"
echo " ✓ Remote branch exists: ${comparisonURL}"
else
......@@ -240,12 +239,27 @@ checkIfRemoteBranchExists(){
checkIfMergeRequestExists(){
echo " · Check if merge request exists - todo"
# echo "$issueTitle"
# curl --silent -H "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/$contentRepositoryID/merge_requests\?state\=all
mergeRequestExists=$(curl --silent -H "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/$contentRepositoryID/merge_requests\?state\=all | $private/lib/jq --arg title "$issueTitle" --raw-output '.[] | select(.title | startswith($title)) | " ✓ Merge request exists (\(.merge_status)): https://source.ind.ie/better/content/merge_requests/\(.iid)"')
if [ -z "$mergeRequestExists" ]; then
echo " ✕ Merge request does *not* exist."
else
echo "$mergeRequestExists"
fi
}
checkIfPublished(){
echo " · Check if content published - todo"
local url="https://better.fyi/${category}/${domain}"
if curl --output /dev/null --silent --head --fail "$url"; then
echo " ✓ Published at ${url}"
else
echo " ✕ Not published."
fi
}
......
......@@ -102,7 +102,8 @@ ensurePersonIsLoggedIn(){
createGlobals(){
contentDirectory=~/better.fyi/content
contentRepositoryID=106
issueTitle="Add entry for ${domain} to ${category}."
categoryCapitalised="$(tr '[:lower:]' '[:upper:]' <<< ${category:0:1})${category:1}"
issueTitle="${categoryCapitalised}: ${domain}"
}
......@@ -191,7 +192,7 @@ openMergeRequest(){
echo " · Opening request to merge saved changes to ${domain} in category ${category} on branch ${branchName} to the master branch."
# Initially, all merge requests are assigned to me (Aral, id=1). We can review this as we go, if necessary.
local response=$(curl --silent -X POST --header "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/$contentRepositoryID/merge_requests --data-urlencode "source_branch=${branchName}" --data-urlencode "target_branch=master" --data-urlencode "assignee_id=1" --data-urlencode "title=${mergeMessage} Closes #${issueIID}.")
local response=$(curl --silent -X POST --header "PRIVATE-TOKEN: ${privateToken}" https://source.ind.ie/api/v3/projects/$contentRepositoryID/merge_requests --data-urlencode "source_branch=${branchName}" --data-urlencode "target_branch=master" --data-urlencode "assignee_id=1" --data-urlencode "title=${issueTitle} Closes #${issueIID}." --data-urlencode "description=${mergeMessage}")
# TODO: Check response for failure and alert the person.
# TODO: Should we be checking for existing merge requests and support updating of merge requests?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment