bytecamp 2021 project

Overview

Calldiff

背景

复杂项目的日常迭代中,研发同学想了解某个改动的影响点,往往需要深入代码细节才能获得尽可能全的 checklist 。然而,由于项目的复杂性,我们获得的 checklist 又难免会有一些遗漏。

为了减轻研发同学的心智负担,辅助同学们更有效地保证服务稳定性,本项目应运而生。

本项目,旨在更加智能地帮助研发同学理清代码改动的影响点,明确上线 checklist ,提升研发同学的幸福感。

设计目标

Git 工具仅提供文本层级改动的追踪,缺少对代码层级的改动的追踪,在研发过程中开发人员需要追踪某一代码改动对其它代码的影响。

  • 设计一个 Golang 程序静态分析工具,当代码发生变更时,提供函数调用链变更的追踪功能
  • 具体地,我们针对不同的 Commit ID ,建立函数调用关系图;对两幅图进行比较及分析,最终输出差异结果(包括 JSON 及 SVG )。

模块分层

编译

make build

运行

./calldiff \
    --url=https://github.com/*.git \
    --dir=/path/to/repo \
    --old=<Commit ID> \
    --new=<Commit ID> \
    --test=true \
    --private=true \
    --unchanged=true \
    --pkg=main

参数

参数 含义 默认值
url Git 远程仓库地址(当本地无目标项目时进行 git clone) null
dir Git 本地仓库地址(当本地无目标项目时,含义为 git clone 本地路径) .
old 用以对比的两个 Commit ID 中,较早的一个 HEAD^
new 用以对比的两个 Commit ID 中,较新的一个 HEAD
test 静态分析时,是否考虑单元测试相关文件 false
private 输出差异时,是否输出未导出的函数 false
unchanged 输出差异时,是否输出未发生变化的函数 false
pkg 输出差异时,输出指定包的差异情况 main

图例

样例

Calldiff 项目

make run

该命令输出当前目录下,HEAD^ 和 HEAD 两个 Commit 的函数调用关系图之间差异。

{
    "pkg": "main",
    "change_list": {
        "modified": [
            {
                "name": "main.main",
                "added_call": null,
                "deleted_call": null,
                "affected_call": [
                    {
                        "name": "diff.(*calldiff/diff.DiffGraph)OutputDiffGraph",
                        "affected_by": [
                            "diff.getModificationDetail"
                        ]
                    }
                ],
                "ast_changed": false
            }
        ],
        "new": null,
        "deleted": null,
        "unchanged": null
    }
}

Dragonfly 项目

./calldiff \
    --url=https://github.com/dragonflyoss/Dragonfly.git \
    --dir=./Dragonfly \
    --old=7856ccdbb1e91bf2fefdc32e030780224f68e4be \
    --pkg=algorithm \
    --test=true

该命令首先会从 github 上 clone 目标项目至 dir 下,并比较 7856ccdbb1e91bf2fefdc32e030780224f68e4be 和 HEAD 两个 Commit 的函数调用关系图之间差异。

{
    "pkg": "server",
    "change_list": {
        "modified": [
            {
                "name": "server.EncodeResponse",
                "added_call": [
                    "api.SendResponse"
                ],
                "deleted_call": null,
                "affected_call": null,
                "ast_changed": true
            },
            {
                "name": "server.handleMetrics",
                "added_call": null,
                "deleted_call": null,
                "affected_call": null,
                "ast_changed": true
            },
            {
                "name": "server.newMetrics",
                "added_call": null,
                "deleted_call": null,
                "affected_call": null,
                "ast_changed": true
            },
            {
                "name": "server.New",
                "added_call": [
                    "preheat.NewManager"
                ],
                "deleted_call": null,
                "affected_call": [
                    {
                        "name": "task.NewManager",
                        "affected_by": [
                            "task.newMetrics"
                        ]
                    }
                ],
                "ast_changed": true
            }
        ],
        "new": [
            "server.createRouter",
            "server.registerCoreHandlers",
            "server.initAPIRoutes$1",
            "server.initDebugRoutes",
            "server.initAPIRoutes",
            "server.registerSystem",
            "server.preheatHandlers",
            "server.httpErr",
            "server.registerLegacy",
            "server.registerV1"
        ],
        "deleted": [
            "server.(github.com/dragonflyoss/Dragonfly/supernode/server.ResultInfo)Error",
            "server.initRoute",
            "server.filter",
            "server.HandleErrorResponse"
        ],
        "unchanged": null
    }
}
You might also like...
Advent of Code 2021, this time in Go

Go Lang Notes Advent of Code Day 3 The distinction between chars and bytes is a bit annoying. I got tripped up by doing: int(str[pos]) which gives yo

My solutions for 2021's Advent of Code

Advent of Code 2021 These are my solutions to this year's Advent of Code. I used it as an excuse to practice with a language which I'm not yet very fa

2021 pingcap talent-plan tinykv
2021 pingcap talent-plan tinykv

The TinyKV Course The TinyKV course builds a key-value storage system with the Raft consensus algorithm. It is inspired by MIT 6.824 and TiKV Project.

🎄 My code for the Advent of Code of year 2021 in Go.

Advent of Code 2021 This repository contains all code that I wrote for the Advent of Code 2021. This year I chose to try and learn Go. Enjoy! Built wi

Advent of Code 2021 (Go)

Advent of Code 2021 (Go) This project includes an implementation of the Advent of Code 2021 problems, implemented in Go. These are ports from my C# so

Solutions to Advent-of-Code 2021, in Go.

🎄 advent-of-code-2021 🎄 Solutions to 2021 Advent of code. Summary Advent of Code is an annual advent-calendar of programming puzzles. Here are my 20

Advent of code 2021 solutions by: me :)

Advent of code 2021 These are my solutions for the advent of code 2021 event. My idea is to solve all the problems in go, but I may use another langua

A little repository for my Advent of Code 2021 solutions in Go

Advent of Code 2021 What's this repo all about? Well, this is a collection of code written in Golang to solve the daily problems presented in Advent o

Advent of Code 2021 solutions using Go 1.18 Generics

advent-of-code-2021 Here are my solutions for Advent of Code 2021. This year, I chose to write my solutions using Go 1.18 with generics (by building t

Owner
null
UCSD CSE 124 Fall 2021 Project 3 Starter Code

Surfstore This is the starter code for Module 3: Surfstore. Before you get started, make sure you understand the following 2 things about Go. (These w

UCSD CSE 124 Fall 2021 0 May 15, 2022
Auto Judger for BUAA-SE-OOP Course (2021 Spring)

patpat Auto Judger for BUAA-SE-OOP Course (2021 Spring) 1. 评测机使用方法 1.1. 一些准备工作 1.1.1. 下载评测机 见 GitHub 中的 Releases,下载对应版本即可。目前提供 Windows, Linux, MacOS(I

null 30 Sep 25, 2022
Code for the keycloak demo for the talk I gave at blablaconf 2021

This demo illustrates the usage of keycloak to secure several service accross different clients using roles. How to Run: From a terminal you need to r

Zakaria Amine 1 Oct 30, 2021
Advent of Code 2021 Solutions

Advent of Code 2021 Solutions for the 2021 Advent of Code Building This project makes use of Go 1.17. go mod download go test ./... Running the Soluti

Nathan Lowe 8 Dec 1, 2022
An easy-to-use Map Reduce Go parallel-computing framework inspired by 2021 6.824 lab1. It supports multiple workers on a single machine right now.

MapReduce This is an easy-to-use Map Reduce Go framework inspired by 2021 6.824 lab1. Feature Multiple workers on single machine right now. Easy to pa

Bo-Wei Chen 196 Nov 14, 2022
Distributed Systems 2021 -- Miniproject 3

Mini_Project3 == A Distributed Auction System == You must implement a distributed auction system using replication: a distributed component which hand

null 0 Dec 1, 2021
Alexandra Ocasio-Cortez, 2021

AOC 2021 These are my solutions for the Advent of Code 2021 challenge. I don't have any particular goals but I'll be writing my solutions in Go to pra

Austin Walela 0 Dec 7, 2021
Finished snippets I did for Advent of Code 2021.

Advent of Code 2021 This repository includes my Go code for the Advent of Code 2021. If you want to solve the puzzles yourself first, do so, then look

Mario Liebisch 0 Dec 25, 2021
Advent of Code 2021 - Time to learn Go

aoc2021 Advent of Code 2021 - Time to learn Go Will contain my solutions for aoc2021, so avoid reading the files in .src/aoc2021/ unless you want spoi

null 1 Dec 22, 2021
Advent of Code 2021, experiment in learning Go

aoc_2021 Advent of Code 2021, experiment in learning Go To run, open a terminal in the root folder of the project and run with go run . <day to run> <

Jonathan den Herder 1 Mar 1, 2022