Exemple #1
0
int main(int argc, char *argv[]) {
    char* issueid;
    char* assignee;
    struct json_object* assignee_obj;
    struct json_object* response;

    char* token = config_get_token();
    char* repo = repo_get_repo();
    struct json_object* edited = json_object_new_object();

    if (token == NULL || repo == NULL)
        return 1;

    if (argc <= 2) {
        fprintf(stderr, "Usage: git assign <issue_id> <assignee>\n");
        return 1;
    }

    issueid = argv[1];
    assignee = argv[2];
    assignee_obj = json_object_new_string(assignee);
    json_object_object_add(edited, "assignee", assignee_obj);

    response = github_edit_issue(repo, issueid, edited, token);
    if (response) {
        printf("Successfully assigned issue #%s to %s\n", issueid, assignee);
        return 0;
    }

    return 1;
}
Exemple #2
0
int main(int argc, char *argv[]) {
    char* issueid;
    struct json_object* issue;

    char* token = config_get_token();
    char* repo = repo_get_repo();

    if (token == NULL || repo == NULL)
        return 1;

    if (argc <= 1) {
        fprintf(stderr, "Usage: git detail <issue_id>\n");
        return 1;
    }

    issueid = argv[1];

    issue = github_get_issue(repo, issueid, token);
    if (issue) {
        print_issue(issue, token, repo);
        return 0;
    }

    return 1;
}
Exemple #3
0
int main(int argc, char *argv[]) {
    int c;
    extern char* optarg;
    struct json_object* response;

    char* title = NULL;
    char* body = NULL;
    char* token = config_get_token();
    char* repo = repo_get_repo();
    char* base = "master";
    char* head = repo_get_branch();
    struct json_object* pr = json_object_new_object();

    if (token == NULL || repo == NULL)
        return 1;

    while ((c = getopt(argc, argv, "t:m:b:h:")) != EOF) {
        switch (c) {
            case 't':
                title = optarg;
                break;
            case 'm':
                body = optarg;
                break;
            case 'b':
                base = optarg;
                break;
            case 'h':
                head = optarg;
                break;
        }
    }
    if (title == NULL || body == NULL) {
        fprintf(stderr, "Usage: git pr -m \"pr body\" -t \"pr title\" [-b base] [-h head]\n");
        return 1;
    }

    json_object_object_add(pr, "title", json_object_new_string(title));
    json_object_object_add(pr, "body", json_object_new_string(body));
    json_object_object_add(pr, "base", json_object_new_string(base));
    json_object_object_add(pr, "head", json_object_new_string(head));
    
    response = github_create_pr(repo, pr, token);
    if (response) {
        printf("Created pr #%s\n", jsonh_get_string(response, "number"));
        return 0;
    }

    return 1;
}
Exemple #4
0
int main(int argc, char *argv[]) {
    int c;
    extern char* optarg;
    struct json_object* response;

    char* title = NULL;
    char* body = NULL;
    char* token = config_get_token();
    char* repo = repo_get_repo();
    struct json_object* issue = json_object_new_object();

    if (token == NULL || repo == NULL)
        return 1;

    while ((c = getopt(argc, argv, "t:m:")) != EOF) {
        switch (c) {
            case 't':
                title = optarg;
                break;
            case 'm':
                body = optarg;
                break;
        }
    }
    if (title == NULL || body == NULL) {
        fprintf(stderr, "Usage: git issue -m \"issue body\" -t \"issue title\"\n");
        return 1;
    }

    json_object_object_add(issue, "title", json_object_new_string(title));
    json_object_object_add(issue, "body", json_object_new_string(body));
    
    response = github_create_issue(repo, issue, token);
    if (response) {
        printf("Created issue #%s\n", jsonh_get_string(response, "number"));
        return 0;
    }

    return 1;
}