new_post.sh: decide a solution for last date situation #1
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
Type/IDP
Type/Server
Type/UI
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: exo/eXOfasia#1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Regarding the correction I had to do to fix the date
03d4ec8f78
Assuming I am not wrong, I suspect that what happened is that the
new_post.sh
script was called two timesAnd that would confirm my suspiction (it is assuming that the already rendered publication might be there)
current_number="$(echo "${publications}" | grep -v "${today}" | wc -l)"
On first time, it successfully got the latest date from the publications directory (but see appendix 1)
On the second time, last publication, is the same publication I am rendering now, and that's how the last date becomes today
I see that for second time it should happen an additional validation:
Get the date from the
yaml front matter
, particularlydate
, and compare if the file already exists in posts dir. If it exists you might want to stop and ask the user to delete it to continue, or delete it (hence override with the new post)In fact, using the var from the
yaml front matter
, it might be better to get the today from thedate
yaml var instead of this commandtoday="$(date +"%Y-%m-%d")"
year
andmonth
are vars not used (by the way, you can inject a specific date todate
shell command, and parse that parts too,-d
argument)Other solution might apply, because there is a lot of ways to do this... let's decide something
Appendix 1
another problem maybe related to freebsd vs linux? In my system that
find
query gives it to me unsorted, and that magic would not work in my case:last_date="$(echo "${publications}" | tail -n 1 | cut -d '/' -f 2)"