2017-06-06 17:45:44 -07:00
|
|
|
#ifndef EDI_SCM_H_
|
|
|
|
# define EDI_SCM_H_
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief These routines are used for Edi SCM management.
|
|
|
|
*/
|
|
|
|
|
2017-08-28 06:01:41 -07:00
|
|
|
typedef enum {
|
2017-09-15 17:19:54 -07:00
|
|
|
EDI_SCM_STATUS_NONE = 0,
|
|
|
|
EDI_SCM_STATUS_ADDED,
|
2017-08-28 06:01:41 -07:00
|
|
|
EDI_SCM_STATUS_DELETED,
|
|
|
|
EDI_SCM_STATUS_MODIFIED,
|
|
|
|
EDI_SCM_STATUS_RENAMED,
|
|
|
|
EDI_SCM_STATUS_UNTRACKED,
|
2017-09-15 17:19:54 -07:00
|
|
|
EDI_SCM_STATUS_ADDED_STAGED,
|
|
|
|
EDI_SCM_STATUS_DELETED_STAGED,
|
|
|
|
EDI_SCM_STATUS_MODIFIED_STAGED,
|
|
|
|
EDI_SCM_STATUS_RENAMED_STAGED,
|
2017-08-28 06:01:41 -07:00
|
|
|
EDI_SCM_STATUS_UNKNOWN,
|
|
|
|
} Edi_Scm_Status_Code;
|
|
|
|
|
|
|
|
typedef struct _Edi_Scm_Status
|
|
|
|
{
|
|
|
|
Eina_Stringshare *path;
|
2017-09-17 08:34:35 -07:00
|
|
|
Eina_Stringshare *fullpath;
|
2017-09-27 11:42:45 -07:00
|
|
|
Eina_Stringshare *unescaped;
|
2017-08-28 06:01:41 -07:00
|
|
|
Edi_Scm_Status_Code change;
|
|
|
|
Eina_Bool staged;
|
|
|
|
} Edi_Scm_Status;
|
|
|
|
|
2017-12-20 13:47:21 -08:00
|
|
|
typedef int (scm_fn_stage)(const char *path);
|
|
|
|
typedef int (scm_fn_unstage)(const char *path);
|
2019-12-15 09:09:12 -08:00
|
|
|
typedef int (scm_fn_undo)(const char *path);
|
2017-06-06 17:45:44 -07:00
|
|
|
typedef int (scm_fn_mod)(const char *path);
|
|
|
|
typedef int (scm_fn_del)(const char *path);
|
|
|
|
typedef int (scm_fn_move)(const char *src, const char *dest);
|
|
|
|
typedef int (scm_fn_commit)(const char *message);
|
|
|
|
typedef int (scm_fn_status)(void);
|
2017-09-21 12:45:33 -07:00
|
|
|
typedef char *(scm_fn_diff)(Eina_Bool);
|
2017-06-06 17:45:44 -07:00
|
|
|
typedef int (scm_fn_push)(void);
|
|
|
|
typedef int (scm_fn_pull)(void);
|
|
|
|
typedef int (scm_fn_stash)(void);
|
2017-08-28 06:01:41 -07:00
|
|
|
typedef Edi_Scm_Status_Code (scm_fn_file_status)(const char *path);
|
2017-06-06 17:45:44 -07:00
|
|
|
|
2017-06-07 14:32:10 -07:00
|
|
|
typedef int (scm_fn_remote_add)(const char *remote_url);
|
2017-06-06 17:45:44 -07:00
|
|
|
typedef const char * (scm_fn_remote_name)(void);
|
|
|
|
typedef const char * (scm_fn_remote_email)(void);
|
|
|
|
typedef const char * (scm_fn_remote_url)(void);
|
2017-06-07 14:32:10 -07:00
|
|
|
typedef int (scm_fn_credentials)(const char *name, const char *email);
|
2017-06-17 04:59:10 -07:00
|
|
|
typedef Eina_List * (scm_fn_status_get)(void);
|
|
|
|
|
2017-06-06 17:45:44 -07:00
|
|
|
typedef struct _Edi_Scm_Engine
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *directory;
|
|
|
|
const char *path;
|
2017-12-28 15:44:28 -08:00
|
|
|
char *root_directory;
|
2017-06-17 04:59:10 -07:00
|
|
|
Eina_List *statuses;
|
2017-06-06 17:45:44 -07:00
|
|
|
|
2017-12-20 13:47:21 -08:00
|
|
|
scm_fn_stage *file_stage;
|
|
|
|
scm_fn_unstage *file_unstage;
|
2019-12-15 09:09:12 -08:00
|
|
|
scm_fn_undo *file_undo;
|
2017-08-28 06:01:41 -07:00
|
|
|
scm_fn_mod *file_mod;
|
|
|
|
scm_fn_del *file_del;
|
|
|
|
scm_fn_move *move;
|
|
|
|
scm_fn_commit *commit;
|
|
|
|
scm_fn_status *status;
|
2017-09-11 08:27:40 -07:00
|
|
|
scm_fn_diff *diff;
|
2017-08-28 06:01:41 -07:00
|
|
|
scm_fn_file_status *file_status;
|
|
|
|
scm_fn_push *push;
|
|
|
|
scm_fn_pull *pull;
|
|
|
|
scm_fn_stash *stash;
|
2017-06-06 17:45:44 -07:00
|
|
|
|
2017-06-07 14:32:10 -07:00
|
|
|
scm_fn_remote_add *remote_add;
|
|
|
|
scm_fn_remote_name *remote_name_get;
|
|
|
|
scm_fn_remote_email *remote_email_get;
|
|
|
|
scm_fn_remote_url *remote_url_get;
|
|
|
|
scm_fn_credentials *credentials_set;
|
2017-06-17 04:59:10 -07:00
|
|
|
scm_fn_status_get *status_get;
|
2017-09-15 17:19:54 -07:00
|
|
|
Eina_Bool initialized;
|
2017-06-06 17:45:44 -07:00
|
|
|
} Edi_Scm_Engine;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Executable helpers
|
|
|
|
* @defgroup Scm
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* Functions of source code management.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init the SCM system for the current project.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
Edi_Scm_Engine *edi_scm_init();
|
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
/**
|
2017-12-30 11:00:04 -08:00
|
|
|
* Init the SCM system for the specified path.
|
|
|
|
*
|
|
|
|
* @param path The location to find the scm information.
|
2017-09-29 13:37:21 -07:00
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
2017-12-30 11:00:04 -08:00
|
|
|
EAPI Edi_Scm_Engine *edi_scm_init_path(const char *path);
|
2017-09-29 13:37:21 -07:00
|
|
|
|
2017-06-06 17:45:44 -07:00
|
|
|
/**
|
|
|
|
* Shutdown and free memory in use by SCM system.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
void edi_scm_shutdown();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up a new git repository for the current project.
|
|
|
|
*
|
2017-06-08 23:13:02 -07:00
|
|
|
* @return The status code of the init command.
|
|
|
|
*
|
2017-06-06 17:45:44 -07:00
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
EAPI int edi_scm_git_new(void);
|
|
|
|
|
2017-06-08 23:13:02 -07:00
|
|
|
/**
|
|
|
|
* Clone an existing git repository from the provided url.
|
|
|
|
*
|
2018-09-03 08:11:09 -07:00
|
|
|
* @param url The URL to clone from.
|
|
|
|
* @param dir The new directory that will be created to clone into.
|
2020-03-13 14:51:06 -07:00
|
|
|
* @param history Whether to clone a full git history or single commit.
|
|
|
|
*
|
2017-06-08 23:13:02 -07:00
|
|
|
* @return The status code of the clone command.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
2020-03-13 14:51:06 -07:00
|
|
|
EAPI int edi_scm_git_clone(const char *url, const char *dir, Eina_Bool history);
|
2017-06-08 23:13:02 -07:00
|
|
|
|
2018-09-03 08:11:09 -07:00
|
|
|
/**
|
|
|
|
* Update a local git repository from remote source.
|
|
|
|
*
|
|
|
|
* @param dir The directory to update.
|
|
|
|
*
|
|
|
|
* @return The status code of the update process.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
EAPI int edi_scm_git_update(const char *dir);
|
|
|
|
|
2017-06-06 17:45:44 -07:00
|
|
|
/**
|
|
|
|
* Get a pointer to the SCM engine in use.
|
|
|
|
*
|
|
|
|
* @return The pointer to the engine or NULL.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
Edi_Scm_Engine *edi_scm_engine_get(void);
|
|
|
|
|
|
|
|
/**
|
2017-12-20 13:47:21 -08:00
|
|
|
* Stage file for commit with SCM.
|
2017-06-06 17:45:44 -07:00
|
|
|
*
|
|
|
|
* @param path The file path.
|
|
|
|
* @return The status code of command executed.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
2017-12-20 13:47:21 -08:00
|
|
|
int edi_scm_stage(const char *path);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unstage file from commit.
|
|
|
|
*
|
|
|
|
* @param path The file path.
|
|
|
|
* @return The status code of command executed.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
int edi_scm_unstage(const char *path);
|
2017-06-06 17:45:44 -07:00
|
|
|
|
2019-12-15 09:09:12 -08:00
|
|
|
/**
|
|
|
|
* Reset file changes to last commit state.
|
|
|
|
*
|
|
|
|
* @param path The file path.
|
|
|
|
* @return The status code of command executed.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
int edi_scm_undo(const char *path);
|
|
|
|
|
2017-06-06 17:45:44 -07:00
|
|
|
/**
|
|
|
|
* Del file from those monitored by SCM.
|
|
|
|
*
|
|
|
|
* @param path The file path.
|
|
|
|
* @return The status code of command executed.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
int edi_scm_del(const char *path);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set commit message for next commit to SCM.
|
|
|
|
*
|
2017-06-18 13:49:53 -07:00
|
|
|
* @param message The commit message to send.
|
2017-06-06 17:45:44 -07:00
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
void edi_scm_commit(const char *message);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get status of repository.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
void edi_scm_status(void);
|
|
|
|
|
2017-08-28 06:01:41 -07:00
|
|
|
/**
|
|
|
|
* Get file status within repository.
|
|
|
|
*
|
|
|
|
* @param path The file path.
|
|
|
|
* @return The status code of the file.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
Edi_Scm_Status_Code edi_scm_file_status(const char *path);
|
|
|
|
|
2017-06-17 04:59:10 -07:00
|
|
|
/**
|
|
|
|
* Get status of repository.
|
|
|
|
*
|
|
|
|
* @return State whether a change was registered (true/false).
|
|
|
|
*/
|
|
|
|
Eina_Bool edi_scm_status_get(void);
|
|
|
|
|
2017-09-11 08:27:40 -07:00
|
|
|
/**
|
|
|
|
* Get diff of changes in repository.
|
|
|
|
*
|
2017-09-21 12:45:33 -07:00
|
|
|
* @param cached Whether the results are general or cached changes.
|
|
|
|
*
|
2017-09-11 08:27:40 -07:00
|
|
|
* @return diff output as a string.
|
|
|
|
*/
|
2017-09-21 12:45:33 -07:00
|
|
|
char *edi_scm_diff(Eina_Bool cached);
|
2017-09-11 08:27:40 -07:00
|
|
|
|
2017-06-06 17:45:44 -07:00
|
|
|
/**
|
|
|
|
* Move from src to dest.
|
|
|
|
*
|
|
|
|
* @param src The source file,
|
|
|
|
* @param dest The destination.
|
|
|
|
*
|
|
|
|
* @return The status code of command executed.
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
int edi_scm_move(const char *src, const char *dest);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set user credentials for the SCM system.
|
|
|
|
*
|
|
|
|
* @param user The name of the user.
|
|
|
|
* @param email The email of the user.
|
|
|
|
*
|
|
|
|
* @return The status code of command executed.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
2017-06-07 14:32:10 -07:00
|
|
|
int edi_scm_credentials_set(const char *user, const char *email);
|
2017-06-06 17:45:44 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Push to SCM remote repository.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
void edi_scm_push(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pull from SCM remote repository.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
void edi_scm_pull(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stash local changes.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
void edi_scm_stash(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set remote url for SCM.
|
|
|
|
*
|
|
|
|
* @param message The remote_url to add.
|
|
|
|
*
|
|
|
|
* @return The status code of command executed.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
int edi_scm_remote_add(const char *remote_url);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test whether SCM is enabled for this project.
|
|
|
|
*
|
|
|
|
* @return Whether SCM is enabled or not (true/false);
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
Eina_Bool edi_scm_enabled(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test whether SCM has a remote enabled for this project.
|
|
|
|
*
|
|
|
|
* @return Whether SCM is remote enabled or not (true/false);
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
Eina_Bool edi_scm_remote_enabled(void);
|
|
|
|
|
2017-06-07 22:38:21 -07:00
|
|
|
/**
|
|
|
|
* Get the URL to an avatar image for the user (based on email).
|
|
|
|
*
|
|
|
|
* @return An allocated string containing the URL or NULL if no email
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
const char *edi_scm_avatar_url_get(const char *email);
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the root directory of the SCM.
|
|
|
|
*
|
|
|
|
* @return The location of the SCM's root working directory.
|
|
|
|
*
|
|
|
|
* @ingroup Scm
|
|
|
|
*/
|
|
|
|
const char *edi_scm_root_directory_get(void);
|
|
|
|
|
2017-06-06 17:45:44 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* EDI_SCM_H_ */
|