Пример #1
0
int main(int argc, char *argv[])
{
    for(int i = 1; i < argc; i++)
    {
        if(argv[i] == NULL) continue;
        if(strncmp(argv[i], "-r", 2) == 0 || strncmp(argv[i], "--replace", 9) == 0)
            allow_replace = true;
        else if(strncmp(argv[i], "-l", 2) == 0 || strncmp(argv[i], "--local", 7) == 0)
            local = true;
        else if(strncmp(argv[i], "-f", 2) == 0 || strncmp(argv[i], "--fetch", 7) == 0)
            do_fetch = true;
        else if(strncmp(argv[i], "-s", 2) == 0 || strncmp(argv[i], "--sql", 5) == 0)
            do_sql = true;
        else if(strncmp(argv[i], "--branch=", 9) == 0)
            snprintf(remote_branch, MAX_REMOTE, "%s", argv[i] + 9);
        else if(strncmp(argv[i], "-h", 2) == 0 || strncmp(argv[i], "--help", 6) == 0)
        {
            printf("Usage: git_id [OPTION]\n");
            printf("Generates a new rev number and updates revision_nr.h and the commit message.\n");
            printf("Should be used just before push.\n");
            printf("   -h, --help            show the usage\n");
            printf("   -r, --replace         replace the rev number if it was already applied\n");
            printf("                         to the last commit\n");
            printf("   -l, --local           search for the highest rev number on HEAD\n");
            printf("   -f, --fetch           fetch from origin before searching for the new rev\n");
            printf("   -s, --sql             search for new sql updates and do all of the changes\n");
            printf("                         for the new rev\n");
            printf("       --branch=BRANCH   specify which remote branch to use\n");
            return 0;
        }
    }

    DO( find_path()                     );
    if(!local)
    {
        DO( find_origin()               );
        if(do_fetch)
            DO( fetch_origin()          );
        DO( check_fwd()                 );
    }
    DO( find_rev()                      );
    DO( find_head_msg()                 );
    if(do_sql)
        DO( find_sql_updates()          );
    DO( prepare_new_index()             );
    DO( write_rev_nr()                  );
    if(do_sql)
    {
        DO( convert_sql_updates()       );
        DO( generate_sql_makefile()     );
        //DO( change_sql_database()       );
        DO( write_rev_sql()             );
    }
    DO( amend_commit()                  );
    DO( cleanup_new_index()             );
    //if(do_sql)
    //    DO( change_sql_history()        );

    return 0;
}
Пример #2
0
int main(int argc, char *argv[])
{
    for(int i = 1; i < argc; i++)
    {
        if(argv[i] == NULL) continue;
        if(strncmp(argv[i], "-r", 2) == 0 || strncmp(argv[i], "--replace", 2) == 0)
            allow_replace = true;
        if(strncmp(argv[i], "-l", 2) == 0 || strncmp(argv[i], "--local", 2) == 0)
            local = true;
        if(strncmp(argv[i], "-f", 2) == 0 || strncmp(argv[i], "--fetch", 2) == 0)
            do_fetch = true;
        if(strncmp(argv[i], "-h", 2) == 0 || strncmp(argv[i], "--help", 2) == 0)
        {
            printf("Usage: git_id [OPTION]\n");
            printf("Generates a new rev number and updates revision_nr.h and the commit message.\n");
            printf("Should be used just before push.\n");
            printf("   -h, --help     show the usage\n");
            printf("   -r, --replace  replace the rev number if it was already applied to the last\n");
            printf("                  commit\n");
            printf("   -l, --local    search for the highest rev number on HEAD\n");
            printf("   -f, --fetch    fetch from origin before searching for the new rev\n");
            return 0;
        }
    }

    DO( find_path()     );
    if(!local)
    {
        DO( find_origin()   );
        if(do_fetch)
        {
            DO( fetch_origin()  );
            DO( check_fwd()     );
        }
    }
    DO( find_rev()      );
    DO( find_head_msg() );
    DO( write_rev()     );
    DO( amend_commit()  );

    return 0;
}