V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
andyhuai
V2EX  ›  程序员

有个想法,想使用 git 提交记录来生成日志博客,该如何实现呢?

  •  
  •   andyhuai · 2019-06-27 14:21:34 +08:00 · 2522 次点击
    这是一个创建于 1736 天前的主题,其中的信息可能已经有所发展或是发生改变。

    想用 github 来实现一个简单的记录心情或者事件的博客, 每个 commit 就会在生成一个状态,包含时间和内如,就像 github 的 release 列表一样。 但是如何读取提交记录呢?没有找到 json 文件什么的, 有知道告知一下;

    另外,有一个 nodejs 实现的类似的项目, https://byronhsu.github.io/life-commit/,大家可以看看

    20 条回复    2019-06-28 16:42:07 +08:00
    jasonsui
        1
    jasonsui  
       2019-06-27 14:54:16 +08:00 via Android
    webhook
    Ritter
        2
    Ritter  
       2019-06-27 15:05:01 +08:00
    插眼等大佬解答
    npe
        3
    npe  
       2019-06-27 15:15:30 +08:00 via Android   ❤️ 1
    花里胡哨。。。
    Sanko
        4
    Sanko  
       2019-06-27 15:37:42 +08:00 via Android
    commit 有长度限制吗
    xaplux
        5
    xaplux  
       2019-06-27 15:38:52 +08:00
    感觉可以用 github 的 api 接口实现,developer.github.com/v3/repos/commits/
    yuankui
        6
    yuankui  
       2019-06-27 15:44:06 +08:00
    http://qinghua.github.io/jgit/

    如果是 java 语言的话,可以用这个库,可以直接读取.git 仓库。包含所有你需要的元数据信息。

    如果是其他语言的话,可以在这里找找:
    https://git-scm.com/book/uz/v2/Appendix-B%3A-Embedding-Git-in-your-Applications-Libgit2
    yuankui
        7
    yuankui  
       2019-06-27 15:45:21 +08:00
    最后的最后,可以寄出大杀器:爬虫。
    KuroNekoFan
        8
    KuroNekoFan  
       2019-06-27 15:47:57 +08:00
    git webhook
    KuroNekoFan
        9
    KuroNekoFan  
       2019-06-27 15:49:02 +08:00
    跟 commit 自动触发 ci/cd 一个道理
    Northxw
        10
    Northxw  
       2019-06-27 15:49:30 +08:00
    爬虫
    moodasmood
        11
    moodasmood  
       2019-06-27 15:50:15 +08:00
    花里胡哨+1
    andyhuai
        12
    andyhuai  
    OP
       2019-06-27 15:58:37 +08:00
    @xaplux 这个貌似比较靠谱的
    @KuroNekoFan webhook,如何拿到我 commit 提交 message 呢?
    KuroNekoFan
        13
    KuroNekoFan  
       2019-06-27 16:08:28 +08:00
    @andyhuai 方法应该不限于一种,就我知道的,git cmd tool,比如
    ```
    git ls-remote --tags ${repoURI}
    ```
    可以拿到这个 repoURI 对应的 tag 信息
    pupboss
        14
    pupboss  
       2019-06-27 16:53:41 +08:00   ❤️ 1
    commit 之前仓库要有改动才行,虽然也很容易实现,我还是想跟风说一个。。。花里胡哨+2
    deepdark
        15
    deepdark  
       2019-06-27 17:10:15 +08:00 via Android
    可以修改覆写.git 目录里的 hooks 文件夹里的内容,你的需求需要修改 post-commit,具体流程就是在你仓库 commit 的时候 bash 脚本拿到 commit msg 然后做你想要的操作,生成 markdown 发布博客或者是调用 web 接口都可以
    jingyulong
        16
    jingyulong  
       2019-06-27 21:54:20 +08:00
    官方接口可以做到啊。。。。。啥数据都有,https://developer.github.com/v4/guides/intro-to-graphql/
    kawana
        17
    kawana  
       2019-06-27 23:37:00 +08:00   ❤️ 1
    @pupboss 不一定需要有改动, `git commit --allow-empty` 可以提交空 commit,不过还是 「花里胡哨」
    andyhuai
        18
    andyhuai  
    OP
       2019-06-28 09:08:42 +08:00
    @kawana 就懒,不想写过多东西,不想买 vps,不想折腾
    JiYouMCC
        19
    JiYouMCC  
       2019-06-28 16:41:00 +08:00
    github api graphql
    JiYouMCC
        20
    JiYouMCC  
       2019-06-28 16:42:07 +08:00
    不一定要 comment,还可以起个 issue,然后用 issue 的帖子内容生成,这样就还能支持修改删除啥的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3595 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 00:10 · PVG 08:10 · LAX 17:10 · JFK 20:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.