Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: store backup in another branch #253

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

HuJJ-NB
Copy link

@HuJJ-NB HuJJ-NB commented Nov 23, 2022

save backups in new branch, and do not change commit log in master branch

@HuJJ-NB
Copy link
Author

HuJJ-NB commented Nov 23, 2022

很抱歉前段时间学校里事情太多忙忘了,这样应该符合要求了。

@HuJJ-NB
Copy link
Author

HuJJ-NB commented Nov 23, 2022

之后您需要新建一个分支专门存放 BACKUP 目录等,可以将 master 分支里的您还需要的文件移动到新分支。大体可以参考我的仓库

Copy link
Owner

@yihong0618 yihong0618 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有些需要修改的

Comment on lines +52 to +65
cp back/README.md main/README.md
cp back/feed.xml main/feed.xml
cd main
git config --local user.email "${{ env.GITHUB_EMAIL }}"
git config --local user.name "${{ env.GITHUB_NAME }}"
git add BACKUP/*.md
git commit -a -m 'update new blog' || echo "nothing to commit"
git push || echo "nothing to push"

git add README.md feed.xml
git commit --amend --no-edit
git push --force
cd ../back
git config --local user.email "${{ env.GITHUB_EMAIL }}"
git config --local user.name "${{ env.GITHUB_NAME }}"
git add .
git commit -m "update new blog"
git push
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥这么复杂。。。

Comment on lines +16 to +18
MD_FOOT = """
---
Thanks for [yihong0618](https://github/com/yihong0618/gitblog)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这句可以不要哈哈,不过没关系,我自己来改也行

[RSS Feed](https://raw.githubusercontent.com/{repo_name}/master/feed.xml)
MD_HEAD = """# Gitblog
My personal blog using issues and GitHub Actions(随意转载,无需署名)
Subscribe to [RSS Feed](https://raw.githubusercontent.com/{repo_name}/master/feed.xml)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 repo_name 是变量?



def add_md_top(repo, md, me):
top_issues = list(get_top_issues(repo))
if not TOP_ISSUES_LABELS or not top_issues:
return
with open(md, "a+", encoding="utf-8") as md:
md.write("## 置顶文章\n")
md.write("\n## 置顶文章\n\n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 Label 不是有么?不加这个也行吧?

Comment on lines +170 to +174
md.write("\n## 友情链接\n\n")
md.write(s)
md.write("\n> 通过向以下 issues 评论的形式,将您的博客加入友链列表\n> \n")
for issue in friends_issues:
md.write(f"> [{issue.title}]({issue.html_url})\n> \n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个很棒,谢谢

Comment on lines +158 to +160
friends_issues = repo.get_issues(labels=FRIENDS_LABELS)
if not FRIENDS_LABELS or not friends_issues:
return
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool



def add_md_recent(repo, md, me, limit=5):
count = 0
with open(md, "a+", encoding="utf-8") as md:
# one the issue that only one issue and delete (pyGitHub raise an exception)
try:
md.write("## 最近更新\n")
md.write("\n## 最近更新\n\n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines 210 to 211
if issues.totalCount:
md.write("## " + label.name + "\n")
issues = sorted(issues, key=lambda x: x.created_at, reverse=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得我之前的方式比较好,用 label 当 title

@yihong0618
Copy link
Owner

之后您需要新建一个分支专门存放 BACKUP 目录等,可以将 master 分支里的您还需要的文件移动到新分支。大体可以参考我的仓库

我懂了,这个我需要考虑下,我想保持原有的

@yihong0618
Copy link
Owner

很抱歉前段时间学校里事情太多忙忘了,这样应该符合要求了。

没关系,哈哈。

有几个我不想动的,你的可以作为 fork 继续更新,因为这个本质上还是私人项目我没有特别想做的通用

  1. 我想保持 back up 在这里
  2. label 作为 title 保持原样

如果你想用你的项目提 PR, 你可以研究下怎么同步我的然后切分支提,这样就没那么多冲突了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants