examples: update examples if repository exists.

This adds a git_update method to the scm lib which we use here
to update the existing examples git repository. This ensures
the developer is always using an up-to-date copy of EFL
examples when creating.
This commit is contained in:
Alastair Poole 2018-09-03 16:11:09 +01:00
parent aeb01d7e0e
commit 227231d06e
3 changed files with 31 additions and 4 deletions

View File

@ -410,8 +410,7 @@ edi_create_example(const char *example_name, const char *parentdir,
INF("Extracting example project \"%s\" at path %s\n", example_name, dest);
if (ecore_file_exists(examplepath))
ERR("TODO: UPDATE NOT IMPLEMENTED");
// status = edi_scm_git_update(examplepath);
status = edi_scm_git_update(examplepath);
else
status = edi_scm_git_clone(EXAMPLES_GIT_URL, examplepath);

View File

@ -85,6 +85,23 @@ edi_scm_git_clone(const char *url, const char *dir)
return code;
}
EAPI int
edi_scm_git_update(const char *dir)
{
char *oldpwd;
int code;
oldpwd = getcwd(NULL, PATH_MAX);
chdir(dir);
code = edi_exe_wait("git fetch origin && git reset --hard origin/master");
chdir(oldpwd);
free(oldpwd);
return code;
}
static int
_edi_scm_git_file_stage(const char *path)
{

View File

@ -128,14 +128,25 @@ EAPI int edi_scm_git_new(void);
/**
* Clone an existing git repository from the provided url.
*
* @param url the URL to clone from.
* @param dir the new directory that will be created to clone into
* @param url The URL to clone from.
* @param dir The new directory that will be created to clone into.
* @return The status code of the clone command.
*
* @ingroup Scm
*/
EAPI int edi_scm_git_clone(const char *url, const char *dir);
/**
* 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);
/**
* Get a pointer to the SCM engine in use.
*